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

1 回表示 (過去 30 日間)
DTU
DTU 2013 年 10 月 19 日
編集済み: Yannick 2013 年 10 月 19 日
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 !!

回答 (1 件)

Yannick
Yannick 2013 年 10 月 19 日
編集済み: Yannick 2013 年 10 月 19 日
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!

Translated by