Help using symolic variable
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2011-10-20
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 个评论
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!