필터 지우기
필터 지우기

substituting values from constant matrix to matrix containing variables

조회 수: 1 (최근 30일)
Neel
Neel 2013년 11월 23일
댓글: iamShreyans 2019년 9월 13일
I am trying to substituting values from constant matrix to matrix containing variables in the equatinon
now 'dJ' is my matrix with variables {sina,cosb,tanc,cotd}
z_old is column matrix has values for {a,b,c,d} in dJ and every time the value changes
z_old = [1 2 3 4]' %initial values of states
while 1
z_new = z_old - s*dJ;
z_old=z_new;
end

답변 (1개)

Walter Roberson
Walter Roberson 2013년 11월 23일
Providing that you are using the symbolic toolbox, see subs()
T = num2cell(z_old);
subs(Dj, {sina, cosb, tanc, cotd}, T)
  댓글 수: 1
iamShreyans
iamShreyans 2019년 9월 13일
Hi, I have a similar problem but your solution doesn't seem to work for me
I have a matrix t = [t1 t2 t3-90], where t1, t2 and t3 are syms variable.
I wish to set all t's to zero value and for this I wrote:
subs(t,{t1, t2, t3},{0, 0, 0})
But the 't' matrix still has the old values. I expected it to change to [0 0 -90] but it didn't happen.

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

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by