For loop with subs

조회 수: 2 (최근 30일)
Ali Tawfik
Ali Tawfik 2019년 7월 14일
답변: TADA 2019년 7월 14일
Hi All,
I have been trying to to have three different matrix based on the values of y , z, however, it's strange, the output matrix of mat is not 1*3 its 4*9 ?
Why can not I have three different matrices (1*3)?
syms l1 l2 real;
x=[2,3,4];
mat=[1 2 3;l1 2 l1];
mat=subs(mat,{l2})
for i=1:3
y=x(i)+1;
z=[1 2 3;4 5 y];
subs(mat,{l1,l2},{y,z})
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 7월 14일
Why would you expect the result of substituting into a 2 x 3 matrix to ever be smaller than 2 x 3?
Ali Tawfik
Ali Tawfik 2019년 7월 14일
Hi Walter,
Thanks for your reply.
I did not say I expect matrix smaller than 2* 3, I said, I would expect the same size, however, the output result is different and bigger ?
So could you please help me ?
Thanks

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

답변 (1개)

TADA
TADA 2019년 7월 14일
You are setting a 2x3 matrix into l2, which duplicates mat for all possible substitutions
2x3 times 2x3 = 4x9

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by