Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to change my code to read a second datafile?
조회 수: 1 (최근 30일)
이전 댓글 표시
I've got a datafile called 'data_stair_rise'. This datafile contains measurements ( being c3dfiles ) for 5 subjects. I've created a code to read these c3dfiles. I also got a second datafile called 'data_sts'. Is it possible to not simple 'copy-paste' my code and switch 'data_stair_rise' by 'data_sts', but to load data_sts by adjusting my code?
This is my code:
aantal_proefpersonen = length(dir('data_stair_rise'))-2;
for welke_pp=1:aantal_proefpersonen %for 5 subjects
myFolder =sprintf('data_stair_rise/pp%c',num2str(welke_pp));
filePattern = fullfile(myFolder,'*.c3d');
c3dFiles = dir(filePattern);
for i_files=1:length(c3dFiles); %for all c3dfiles for each subject
baseFileName = c3dFiles(i_files).name;
fullFileName = fullfile(myFolder, baseFileName);
[VideoSignals,VideoSignals_headers,AnalogSignals,AnalogSignals_headers,AnalogFrameRate,VideoFrameRate] = read_c3d_file(fullFileName); %function to read the c3dfiles
data_stair_rise(welke_pp, i_files).VideoSignals = VideoSignals; % created a struct to store the data
data_stair_rise(welke_pp, i_files).VideoSignals_headers = VideoSignals_headers;
data_stair_rise(welke_pp, i_files).AnalogSignals = AnalogSignals;
data_stair_rise(welke_pp, i_files).AnalogSignals_headers = AnalogSignals_headers;
data_stair_rise(welke_pp, i_files).AnalogFrameRate = AnalogFrameRate;
data_stair_rise(welke_pp, i_files).VideoFrameRate = VideoFrameRate;
end
end
댓글 수: 6
dpb
2014년 12월 26일
Same as I said originally except hardcode those filenames into the top-level routine and then call the generic one with those names in a loop.
Or, use the dir solution and get
d=dir('data_*.*');
and loop thru it. If there are ones that aren't wanted, skip 'em or revise the naming scheme to have a better pattern-matching facility.
There are as many ways as people to suggest them...
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!