Importing multiple CSV files to process in a loop...
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I have around 60 CSV files I need to import to a script all of which have names like trial02, trial03, trial04 etc. and I only wish to take one column from each to be processed, also they are not the same length, here is what I have so far...
%%Define Variables
nsub=70; %Number of subjects
g=-9.81; %gravity
freq=1/1000; %sample freqency (1000Hz)
%%Importing Files
for i=2:nsub
trail1=-xlsread('groupAmain/Trial0.CSV', 'Trial02', 'E6:E2337');
%%Calculating Jump Height
ftest=find(trail1<=0);%How many 0 readings
ft=length(ftest)*0.001; %Time of flight
pk_disp=(0*(ft/2))-(0.5*g*(ft/2)^2); %Peak Jump Height using vt-0.5*a*t^2
end
Thanks
1 个评论
dpb
2014-4-16
I'd go at it a little differently but before posting specific code, what's in the remaining columns? Since you don't know the length a priori and xlsread needs a square boundary, I'd look at just reading the file and throwing away the columns you don't need. If it's all numeric that's trivial, if mixed types a little more effort but as long as all are same data in same columns, no big deal. But need to know that much at least...
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!