How to solve this structural question using MATLAB?

16 ビュー (過去 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 Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by