How can I load a sequence of csv files and process them by subsets

1 次查看(过去 30 天)
Dear all,
This might be a fairly trivial question, but given that I'm very new to Matlab I've not been able to sort this out by myself.
I've a number of files that I need to process in batches files at a time. The files' name has two different parts: a descriptive part e a numeric part, as in the example below:
a_1.csv; a_2.csv;...; a_n.csv
b_1.csv; b_2.csv;...; b_n.csv
c_1.csv; c_2.csv;...; c_n.csv
...
x_1.csv; x_2.csv;...; x_n.csv
The idea is that at each time I apply a function to a_1 to x_1 files, then a_2 to x_2 files, and so on. After each run I'll get a value out of the function, which will then be stored in a vector of length n. I reckon I should use a for loop to go through all files getting each time all files ending with 1 (or whatever number) and then apply the function, and then again and again. My issue here is that I've not been able to the subseting to run each set of files at a time.
Any help with this would be very much appreciated.
  1 个评论
Jan
Jan 2016-3-19
The question is not clear. What exactly is the problem? What have you tried so far? Is the creation of the file names the problem, or the processing of the files, storing the results or anything else?

请先登录,再进行评论。

采纳的回答

Dave Behera
Dave Behera 2016-3-22
I believe that you are referring to the files a_i.csv-x_i.csv where I ranges from 1 to n, as your 'subsets'.
If that is the case, then you can use a for loop that ranges from 1 to n. Inside each such loop use another for loop to go from files a_i.csv to x_i.csv:
for i= 1:n str = 'abcdefghijklmnopqrstuvwx'; for j = 1:length(str) filename = [str[j] '_' num2str(i) '.csv']; %use csvread to read file and update your vector %your code here end end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by