make while loop into vector so I can save as .mat file

Whenever I run my code, it displays properly in my command window, but I want it to be saved in my
workspace so that I can save the entire calendar as a .mat file.
Here is my code:

1 件のコメント

Adam
Adam 2017 年 3 月 24 日
Please read this to make it easier for us to answer your question. I have done it myself this time.

サインインしてコメントする。

 採用された回答

Adam
Adam 2017 年 3 月 24 日
編集済み: Adam 2017 年 3 月 24 日

1 投票

Replace
fprintf('January %d\n',i);
with
result{i} = sprintf('January %d\n',i);
and the same for all the others, and declare
result = cell( 365, 1 );
at the top. Also why not just use a for loop - it is simpler.
I'm sure there is also a far better way to do this vectorised, but this is just an adaptation of your code. I don't really have time to find a fancy solution, but this should work.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2017 年 3 月 24 日

編集済み:

2017 年 3 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by