How to solve this structural question using MATLAB?
3 次查看(过去 30 天)
显示 更早的评论
Hello all,
So I know how to get matrix A, but then there are some values in A which depend on x. I don't know how to continue from there.
Any help would be really appreciated.
Thanks

A = [-1 0 -1 0 0 0 0 0 0;0 1 0 -1 0 0 0 0 0;0 x-2 1 2-x 0 0 0 0 0;1 0 1 0 1 0 0 0 0;0 -1 0 1 0 1 0 0 0; 0 0 -1 0 0 -x 0 0 0;0 0 1 0 -1 0 -1 0 0;0 0 0 1 0 -1 0 1 0;0 0 0 x -1 0 0 0 1];
b = [0;1;0;0;0;0;0;0;0];
if x == 0:2
n == A\b
end
1 个评论
Walter Roberson
2018-9-14
Are you permitted to use the Symbolic Toolbox?
Note:
In MATLAB, expressions of the form
if A RELATIONSHIP B
where A is a scalar and B is a vector, proceed checking the relationship between the scalar A and each member of B individually, calculating a logical vector of results. Then the if of that logical vector is considered satisfied if all of the elements in your logical vector are true. In terms of your expression, for the if to be considered true, you would need a scalar x value that was simultaneously equal to 0 and equal to 1 and equal to 2 ... which is not possible.
You might be looking for
if x >= 0 && x <= 2
or you might be looking for
if any(x == 0:2)
or
if ismember(x, 0:2)
回答(1 个)
KSSV
2018-9-14
x = 0:2 ;
A = @(x) [-1 0 -1 0 0 0 0 0 0;
0 1 0 -1 0 0 0 0 0;
0 x-2 1 2-x 0 0 0 0 0;
1 0 1 0 1 0 0 0 0;
0 -1 0 1 0 1 0 0 0;
0 0 -1 0 0 -x 0 0 0;
0 0 1 0 -1 0 -1 0 0;
0 0 0 1 0 -1 0 1 0;
0 0 0 x -1 0 0 0 1];
b = [0;1;0;0;0;0;0;0;0];
n = zeros(length(b),length(x)) ;
for i = 1:length(x)
n(:,i) = A(x(i))\b ;
end
But you need to check either A or feasible values of x....solution is always nan.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!