MATLAB Answers

0

Displaying for loop iterations as a matrix

Asked by Abigail Osborne on 18 Feb 2019
Latest activity Answered by Star Strider
on 18 Feb 2019
for R=0.6:0.05:0.95;
A=[(1.5*R-1.59), 0.5*R, 0; 0.5, -21.75, 0; 0, 0, 0];
B=[-0.7; -38; 0];
a=Guass(A,B);
Ci= a(2,2)/a(2,4)
Cu= (a(1,4)-a(1,2)*Ci)/a(1,1)
Liver= [R;Ci]
Lung= [R;Cu]
end
So this code will display Ci and Cu as its individual outputs for each iterations, but I want it displayed as a matrix but when I try displaying Liver and Lung it only displays the last iterations. How can I make it display all the iterations?

  0 Comments

Sign in to comment.

1 Answer

Answer by Star Strider
on 18 Feb 2019

I am guessing here:
Rv=0.6:0.05:0.95;
for k1 = 1:numel(Rv)
R = Rv(k1);
A=[(1.5*R-1.59), 0.5*R, 0; 0.5, -21.75, 0; 0, 0, 0];
B=[-0.7; -38; 0];
a=Guass(A,B);
Ci= a(2,2)/a(2,4)
Cu= (a(1,4)-a(1,2)*Ci)/a(1,1)
Liver{k1}= [R;Ci]
Lung{k1}= [R;Cu]
end
I am using cell arrays for ‘Liver’ and ‘Lung’ because I have no idea what they are, much less their dimensions.

  0 Comments

Sign in to comment.