I have a script which reads .dat files into matlab. I have written the script to work for any year, as in the specific year that you type in the beginning. I am just wondering how to change to code so that I can use it for more than one year of data, my code is:
files = dir('*.dat');
Year=input('year:');
for i=1:length(files);
File_Name{i}=files(i,1).name;
data{i}=importdata(File_Name{i});
data{i}=data{i}(1:2:end,:);
data{i}=data{i}(:,2:end);
data1=cell2mat(data');
Y_data=find(data1(:,1) == Year);
Y_data=data1(Y_data,:);
end
So, at the minute Y_data is a matrix for the data from 2007. I want Y_data to give me 3 matrices, one for 2007, one for 2008, and the other for 2009. I want to know how it would be possible to say in the beginning that Year can be equal to more than one year so that during the end of the loop you can create more than one matrix, if that makes sense.
cheers