Help using symolic variable
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to implement a piece of code:
n = 1000;
syms l;
m = sym('m', [ 1 n ] );
x = sym( 0 );
for i =1:1:n
J_j(1,i) = [ (1/3)*m(1,i)*l*l x x -(1/2)*m(1,i)*l;
x x x x;
x x x x;
-(1/2)*m(1,i)*l x x m(1,i) ];
end
Now, when I try to implement this code, it gives me following error:
??? Error using ==> mupadmex
Error in MuPAD command: Invalid index [list];
during evaluation of 'matchNonSingletonLHS'
Error in ==> sym.sym>sym.subsasgn at 1435
C = mupadmex('symobj::subsasgn',A.s,B.s,inds{:});
can anyone help?
Thank you so much in advance.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 20 Okt. 2011
When you use [] in that J_j assignment statement, you are constructing a 4x4 MATLAB array of symbolic values. A 4x4 MATLAB array cannot fit in to a single array element J_j(1,i) .
A symbolic array can be a single "object" that happens to store 4x4 in it, but such arrays have to be constructed at the MuPad level, or by using sym() with array notation and then subs() in to elements of the resulting symbolic array.
0 Kommentare
Weitere Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!