필터 지우기
필터 지우기

'subs' not working as i want

조회 수: 1 (최근 30일)
Fernando Pérez Lara
Fernando Pérez Lara 2018년 12월 8일
댓글: Fernando Pérez Lara 2018년 12월 9일
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
YT
YT 2018년 12월 8일
편집: YT 2018년 12월 8일
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?
Fernando Pérez Lara
Fernando Pérez Lara 2018년 12월 9일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 12월 8일
Do both subs at the same time
subs(eq, {x, I}, {A, eye(3)})
  댓글 수: 1
Fernando Pérez Lara
Fernando Pérez Lara 2018년 12월 9일
It works! Thank you very much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by