Problem using subs in syms with matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Saurav Agarwal
el 14 de Mayo de 2012
Comentada: rajasekhar reddy ogirala
el 3 de Mzo. de 2014
syms a b q;
c=q*a+b;
d=c(1);
e=c(2);
f=c(3);
a=[1 2 3]';
b=[4 5 6]';
q=[1 9 0;
2 3 4;
3 5 4];
c=subs(c)
d=subs(d)
e=subs(e)
f=subs(f)
The variable c will be a 3X1 matrix and I wanna extract the individual elements for further operation. Please Help!
I get the error
??? Error using ==> mupadmex Error in MuPAD command: Index exceeds matrix dimensions.
Error in ==> sym.sym>sym.subsref at 1381 B = mupadmex('symobj::subsref',A.s,inds{:});
Error in ==> Untitled2 at 5 e=c(2);
0 comentarios
Respuesta aceptada
Andrei Bobrov
el 14 de Mayo de 2012
b = sym('b',[3 1])
a = sym('a',[3 1])
q = sym('q',[3 3])
a1 = [1 2 3]';
b1 = [4 5 6]';
q1 = [1 9 0;
2 3 4;
3 5 4];
d = c(1)
d = subs(d,[a(:);b(:);q(:)],[a1(:);b1(:);q1(:)])
2 comentarios
rajasekhar reddy ogirala
el 3 de Mzo. de 2014
error msg to below program in image is
Error in sym/subsref
B = mupadmex('symobj::subsref',A.s,inds{:});
in line 41
gp = eval(f(z)/(f(z)-f(y)));
Más respuestas (1)
Alexander
el 14 de Mayo de 2012
The error raises in these lines:
d=c(1);
e=c(2);
f=c(3);
The variable c is a (1x1) sym and MATLAB cannot access the 2nd or 3rd element. From the code I guess, you want to substitute q by some values? If I'm wrong, please let me know what you want to achieve by c(1), c(2), and c(3). Following I assume you want to substitute q:
syms a b q c(q);
c(q)=q*a+b;
d=c(1);
e=c(2);
f=c(3);
a=[1 2 3]';
b=[4 5 6]';
q=[1 9 0;
2 3 4;
3 5 4];
d=subs(d)
e=subs(e)
f=subs(f)
If you have an older version, you have to substitute q:
syms a b q;
c=q*a+b;
d=subs(c, q, 1);
e=subs(c, q, 2);
f=subs(c, q, 3);
a=[1 2 3]';
b=[4 5 6]';
q=[1 9 0;
2 3 4;
3 5 4];
d=subs(d)
e=subs(e)
f=subs(f)
2 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!