how to store MATRIX in each iteration

3 views (last 30 days)
i want to store matrix " A" data for each iteration for verification purpose only
Ca=[ca1 ca2;ca3 ca4]; Cb=[cb1 cb2;cb3 cb4]; Cd=[cd1 cd2;cd3 cd4]; Cc=[cc1 cc2;cc3 cc4];
Ka=[ka1 ka2;ka3 ka4]; Kb=[kb1 kb2;kb3 kb4]; Kd=[kd1 kd2;kd3 kd4]; Kc=[kc1 kc2;kc3 kc4];
Ma=[ma 0;0 ma]; Mb=[mb 0;0 mb];
w=[2 4 6];
for i=1:54
s(i)=w(i);
A=[Ma*(s(i)^2)+(Ca+Cb)*s(i)+(Ka+Kb) -(Cb*s(i)+Kb) zeros(2);
-(Cb*s(i)+Kb) Mb*(s(i)^2)+(Cb+Cc+Cd)*s(i)+(Kb+Kc+Kd) -(Cc*s(i)+Kc);
zeros(2) -(Cc*s(i)+Kc) Mc*(s(i)^2)+Cc*s(i)+Kc];
end

Accepted Answer

Ameer Hamza
Ameer Hamza on 2 Apr 2020
Edited: Ameer Hamza on 2 Apr 2020
Store it as cell array
A{i}=[Ma*(s(i)^2)+(Ca+Cb)*s(i)+(Ka+Kb) -(Cb*s(i)+Kb) zeros(2);
-(Cb*s(i)+Kb) Mb*(s(i)^2)+(Cb+Cc+Cd)*s(i)+(Kb+Kc+Kd) -(Cc*s(i)+Kc);
zeros(2) -(Cc*s(i)+Kc) Mc*(s(i)^2)+Cc*s(i)+Kc];
You can then access the stored matrices with
A{1} % A matrix for i=1
A{2} % A matrix for i=2
A{3} % A matrix for i=3
.
.
.
  2 Comments
veeresh g
veeresh g on 3 Apr 2020
Edited: veeresh g on 3 Apr 2020
thanq sir..its working..

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!