csvread Loop Input with Changing String Name
Show older comments
I am trying to read in several files that change depending on a) name, and b) task. An example file is:
'resp_signal_ben_15_brpm.csv'
Other files are the same but have either the name (ben) or the task (15 brpm) changed. I tried to make a few arrays containing the changing parameters, i.e.:
task = ['6_brpm','10_brpm','15_brpm','24_brpm','hold_breath','silent_talk']
name = ['ben','joe','bob']
Then create a nested loop that would insert the appropriate name and task:
for i = 1:3
for j = 1:6
a = csvread('resp_signal_',name(i),'_',task(j),'.csv');
subplot(2,3,i);
plot(a(:,2));
end
end
However, this does not work and I'm sure it probably has to do with the way csvread is taking in these arguments. Can anyone help me with an iterative way read in these files correctly?
1 Comment
per isakson
on 17 Jun 2015
Try replace
a = csvread('resp_signal_',name(i),'_',task(j),'.csv');
by
a = csvread(['resp_signal_',name(i),'_',task(j),'.csv']);
Accepted Answer
More Answers (0)
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!