How to save each value from an iterative solution
Show older comments
Hello,
I am using an iterative solver and would like to be able to save each solution so that they can be plotted.
For the simplified example below:
y=4;%initial value of y
x=[1:5];
for i=1:5;
y=y+x(i);
end
I would like to have each value for y saved as a separate variable in the workspace so that these can be plotted. Something like:
y1 = 5;
y2 = 7;
y3 = 10;
y4 = 14;
y5 = 19;
Y=[y1,y2,y3,y4,y5];
plot(x,Y);
Alternatively if these values for y can be concatenated directly it would be just as useful.
Many thanks
Gareth
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!