How to solve this structural question using MATLAB?
조회 수: 22 (최근 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!