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!