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

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일
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 Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

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