Can you help me with this easy loop task?
Show older comments
Hello i need some help with an easy task.
I have a folder called rpm_measurements and inside of it a lot of folders called rpm0x00 (for example in the code below you can see rpm0800).
What i need is a loop to make the process you see but for each folder of my rpm_measurements folder , not only for one, as it is below.
Can you help me?
workfolder='C:\Users\Jorge\Desktop\Work_Christmas\Measurements\rpm_measurements\rpm0800\';
folders=[
{'cdaq2mod2_ai0-hw\'}
{'cdaq2mod2_ai1-hw\'}
];
file_data=dir([workfolder folders{1} 'x*.dat']);
for i=1:length(file_data);
files(i,1)={file_data(i).name};
end
delimiterIn='\t';
headerlinesIn=11;
for i=1:length(files)
for k=1:length(folders)
filepath = [workfolder folders{k} files{i,1}];
A=importdata(filepath,delimiterIn,headerlinesIn);
vel(:,k,i)=A.data(:,3);
end
end
Accepted Answer
More Answers (1)
Image Analyst
on 2 Jan 2015
0 votes
Attached is some code that might help. It will recurse into all subfolders and find the files. You won't have to know the folder names and hard code them in like you did.
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!