Try to store data in 2 for loops

1 回表示 (過去 30 日間)
Sam
Sam 2014 年 12 月 23 日
コメント済み: Sam 2014 年 12 月 23 日
I've got 2 for loops. The first for loop is for 5 subjects. The second for loop is for 4 measurements. I want to store a figure for subject1, trial1; subject1, trial2; subject1, trial3,...subject5, trial 4.
for welke_pp=1:aantal_pp %for loop for 5 subjects
...
for i_testen=1:length(data_stair_rise)-1 %for loop for 4 measurements
...
folder = 'Data_examen'
pngFileName = sprintf('plot_subject1_trial%d.png', i_testen);
fullFileName = fullfile(folder, pngFileName);
saveas(gcf,fullFileName);
As you can see, at the end op 'pngFileName' I typed only 'i_testen'. So Matlab only stores the figures for trial1,2,3 and 4. But now I want to store the trials for each subject. How do I do this?

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 12 月 23 日
Sam - use the subject number in our output image name. Something like
pngFileName = sprintf('plot_subject%d_trial%d.png', welke_pp, i_testen);
Now, 20 files should be created, four for each subject.
  1 件のコメント
Sam
Sam 2014 年 12 月 23 日
Thanks a lot!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by