How to plot multiple iterations of a while loop on one plot? [MATLAB]

  • MATLAB
  • Thread starter nickadams
  • Start date
  • #1
182
0

Main Question or Discussion Point

If I want to plot multiple iterations of a while loop on one plot, how can I do that? Every time I use "hold on", it just distorts the original line after every iteration instead of drawing independent lines.

Please help
 

Answers and Replies

  • #2
MATLABdude
Science Advisor
1,655
4
I'd just build up a vector or array of values.

For instance, if you're plotting the convergence (the difference between the iterative result and the 'real' result), I'd just concatenate the value onto the vector of error values:
>> delta=[delta, loop_delta];

If, instead, you're generating an entire vector of values, I'd just build up an array, and then plot them all at the end.

Good luck!
 

Related Threads on How to plot multiple iterations of a while loop on one plot? [MATLAB]

Replies
1
Views
5K
  • Last Post
Replies
2
Views
4K
Replies
6
Views
17K
Replies
3
Views
2K
Replies
2
Views
899
Replies
1
Views
4K
Replies
2
Views
42K
  • Last Post
Replies
1
Views
52K
Top