how to save data in for loop?
2 ビュー (過去 30 日間)
古いコメントを表示
I want to save the data in for loop but it only gives me the last data. How can I accumulate the data in row?
----------------------------
Month ={'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'};
m=[];
for year = 2000:2001
for month = 1:12
m=sprintf('%04d%s', year, Month{month});
end
end
0 件のコメント
採用された回答
Azzi Abdelmalek
2013 年 2 月 21 日
m{end+1}=sprintf('%04d%s', year, Month{month});
3 件のコメント
Azzi Abdelmalek
2013 年 2 月 21 日
編集済み: Azzi Abdelmalek
2013 年 2 月 21 日
m is a cell array indicated by { }
help cell
if m=[ 1 2 5] then m(end)=5,
when you type m(end+1) it means m(3+1)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!