How to save an array individually to avoid overwrite in a loop

1 回表示 (過去 30 日間)
Jung
Jung 2016 年 2 月 4 日
回答済み: Walter Roberson 2016 年 2 月 4 日
Hello,
So I managed to open sequence of files in Matlab using the following functions;
for k = 2010:2100
myfilename = sprintf('maxt_%d.pnt', k);
mydata = load(myfilename);
end
Here, because I don't save the array, the data gets overwritten and only show the last year data 'maxt_2100.pnt'. I tried mydata{k} within for loop but doesn't seem to work. Any idea how to save the data inside the loop individually so I can use them outside of the loop?
Thanks in advance

採用された回答

Walter Roberson
Walter Roberson 2016 年 2 月 4 日
for k = 2010:2100
myfilename = sprintf('maxt_%d.pnt', k);
mydata{k-2010+1} = load(myfilename);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by