How to store data after 2 forloops?

조회 수: 1 (최근 30일)
Sam
Sam 2015년 1월 6일
댓글: Guillaume 2015년 1월 6일
I've got this code:
for welke_pp=1:5 %for 5 subjects
for i_testen = 1:5 %for 5 measurements
RHEE = data_stair_rise(welke_pp,i_testen).VideoSignals(:, strcmp('RHEE', data_stair_rise(welke_pp,i_testen).VideoSignals_headers),3); %extract data
RHEE (Right-Heel-marker) is this type: 359x1 double. I want to store RHEE for each subject and each measurment.
When I put RHEE(welke_pp,i_testen) = ... It doesn't work: "Subscripted assignment dimension mismatch." When I use these brackets {} it also doesn't work (but I also don't want to create a cell, so it doesn't matter). Help?

답변 (1개)

Guillaume
Guillaume 2015년 1월 6일
Try:
RHEE = zeros(5, 5, 359);
for welke_pp=1:5 %for 5 subjects
for i_testen = 1:5 %for 5 measurements
RHEE(welke_pp, i_testen, :) = ...
end
end
RHEE will be a 3D array.
  댓글 수: 2
Sam
Sam 2015년 1월 6일
I can't use zeros(5,5,359) because RHEE always has a different length...
Guillaume
Guillaume 2015년 1월 6일
Then you can't store it in a matrix and have to use a cell array:
RHEE{welke_pp, i_testen} = ... %no need to predeclare
or an array of structures with only one field.
RHEE(welke_pp, i_testen).data = ...
A cell array would make more sense / be easier to manipulate.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by