MATLAB Answers

0

'subs' not working as i want

Asked by Fernando Pérez Lara on 8 Dec 2018 at 19:07
Latest activity Commented on by Fernando Pérez Lara on 9 Dec 2018 at 9:24
Hello guys,
I have this equation -x^2/2 + 2*x - (5*I)/2 and I'm trying to replace the letter x with a the matrix A and the letter I with the matrix B.
A = 0 1 0
0 0 1
2 -5 4
B = eye(3)
The problem is that when I write subs(eq, x, A) and subs(eq, I, eye(3)) I get a very big matrix, and this is not the answer.

  2 Comments

YT
on 8 Dec 2018 at 19:55
It makes sense that your result will be "a very big matrix". subs(eq, x, A) will give you a 3x3 matrix because you substitute x for a 3x3 matrix. With subs(eq, I, eye(3)) you are trying to substiute an identity matrix in your previous subsituted matrix. So what do you expect the result to be then?
Yes, you are right, but I didn't know how to use the subs. One guy gave me the correct answer. Thank you for your contribution

Sign in to comment.

1 Answer

Answer by Walter Roberson
on 8 Dec 2018 at 20:54
 Accepted Answer

Do both subs at the same time
subs(eq, {x, I}, {A, eye(3)})

  1 Comment

It works! Thank you very much.

Sign in to comment.