How to solve this structural question using MATLAB?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Walter Roberson
am 14 Sep. 2018
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)
Antworten (1)
KSSV
am 14 Sep. 2018
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 Kommentare
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!