How can I gather all the values from a loop into an array?
Show older comments
Hi,
I was wondering how can I gather all the values into an array because I need to plot the answer later. This is part of the code I am writing:
for i=x0:h1:xx-h1 % Where h1 is the step size
y1=y1+dy(i,y1)*h1;
i=i+h1;
end
If someone knows, please let me know! Thanks!
3 Comments
KSSV
on 5 May 2020
cannot exacly help unless full code is known. You save values in loop as:
n = 10 ;
y = zeros(n,1) ;
for i = 1:n
y(i) = rand ;
end
Raquel Terrer van Gool
on 5 May 2020
Raquel Terrer van Gool
on 5 May 2020
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!