Info
This question is closed. Reopen it to edit or answer.
How to use the result from a step as an input for the next step?
1 view (last 30 days)
Show older comments
Dear all,
Considering the following example, I would like to ask 2 questions:
function example1
Yinitial=zeros(3,1);
A=rand(3,3);
B=rand(3,5);
for nt=1:5
F1=B(:,nt);
F2=Yinitial;
F=F1+F2;
Y=A\F;
end
Yinital=Y;
end
1. Do you know how can I use the result vector Y1={a1,b1,c1} from nt=1 as an input ( initial condition) for the next step, nt=2? Then again the result from nt=2, Y2={a2,b2,c2} as an initial for nt=3 and so on.
2. How can I store the result vectors Ynt into the common two dimensional array: Z={res.Y1,res. Y2, ....,res.Ynt} ?
Thank you in advance!
Regards
Answers (1)
Andrei Bobrov
on 21 Apr 2012
[EDIT]
A=rand(3,3);
B=rand(3,5);
Y = zeros(size(B));
n = 1;
for nt=1:5
if nt > 1, n = nt - 1; end
Y(:,nt)=A\(B(:,nt) + Y(:,n));
end
added after Chervov's comments
Y = zeros(size(B,1),1);
n = 1;
for nt=1:5
Y=A\(B(:,nt) + Y);
end
1 Comment
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!