I want to save an array which change its size at each iteration in a loop so that I can plot later on

2 views (last 30 days)
I am working with adaptive mesh which change its size and hence solution size in a loop. I want to save this adaptive mesh say x and function f(x) in a file inside the loop (in Matlab) so that I can plot how x and f(x) change during the loop. Pls. help me out. Thanks in advance !!

Answers (1)

Yannick
Yannick on 19 Oct 2013
Edited: Yannick on 19 Oct 2013
Hi, you can do a few things:
  • Use SAVE and LOAD to save the data in a MAT-file, and to re-load it later into MATLAB for plotting.
  • Collect the x's and f(x)'s in cell arrays, where the index can indicate the loop iteration in which they were generated.
The second option is probably best as long as you don't run out of memory. If that's the case, then using files to periodically save the data will help. And depending on exactly what you want to achieve, yet other methods can be preferable, but that depends on the specifics of your application. For example, how to import/export data from files.
Hope this help!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!