How to solve this structural question using MATLAB?

조회 수: 22 (최근 30일)
Mohammadamin Malek Pour
Mohammadamin Malek Pour 2018년 9월 13일
답변: KSSV 2018년 9월 14일
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
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
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.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by