Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Output of For-loop in 1 file

1 回表示 (過去 30 日間)
Sam
Sam 2014 年 12 月 19 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have a for-loop for 5 measurements. The first time it runs I get the output for the first measurement. The second time it runs, I get the output for the second measurement. But the output for the first measurement disappears. I know I need to save, but I want to see all the outputdata into 1 file. In 5 columns next to each other. How do I do this?
for i_testen=1:length(data_stair_rise)
RANK = data_stair_rise(1,i_testen).VideoSignals(:, strcmp('RANK', data_stair_rise(1, i_testen).VideoSignals_headers))
RANK = abs(RANK)
figure;
plot(RANK, 'g', 'LineWidth', 2);
ylabel('Distance');
xlabel('Datapoint');
title('Walking stairs', 'FontSize', 16);
legend({'Right ankle'})
xy = ginput(2);
xy(1,1) = 0;
Afstand_1schrede = xy(2,2)-xy(1,2);}
end
I want to save 'Afstand_1schrede' in 1 file with five columns (representing the 5 measurements op 1 subject).

回答 (1 件)

Geoff Hayes
Geoff Hayes 2014 年 12 月 19 日
編集済み: Geoff Hayes 2014 年 12 月 20 日
Sam - you need to use Afstand_1schrede as an array rather than a scalar. Try the following
% create the 1x5 array
Afstand_1schrede = zeros(1,length(data_stair_rise));
for i_testen=1:length(data_stair_rise)
% etc.
% save the measurement
Afstand_1schrede(1,i_testen) = xy(2,2)-xy(1,2);
end
  2 件のコメント
Sam
Sam 2014 年 12 月 19 日
Thanks for your answer, but Matlab gives the following error:
"Subscript indices must either be real positive integers or logicals."
Geoff Hayes
Geoff Hayes 2014 年 12 月 20 日
My mistake, should be i_testen instead of i in the update to the array.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by