Hi all. I have a couple of csv files I need to analyse (1488 files, each having 3 columns and 2304 rows containing only numerical values). I would like my script to open these csv files one by one and extrapolate the informations I need. For example, the script opens the first file, does its calculations, stores these 2 relevant values (that are unique to that file) and then moves on to the next file repeating the same calculations. The script I have right now does this but just for one file. How do I change the script so that it proceeds file by file and stores the obtained values?
1:All the files are contained in the same foulder
2: The first row of the file is Text, this is why i use :
vector=csvread(filename,1);
3: The relevant values I want the script to save before it moves to the next file are: Hav and Tz (at the end of the script).
4: What I'm struggling with here is to give Matlab the right order to do things: ie: open file-->do the calculations--->store the values----> open new file-->repeat the same calculations etc.
Thanks.
filename='2016\May\2016-05-31T23h36.csv';
vector=csvread(filename,1);
eta = vector(:,1)/100;
north = vector(:,2)/100;
west = vector(:,3)/100;
eta = eta - mean(eta);
sr=length(eta)/(30*60);
dt=1/sr;
for i=1:length(eta)
t(i)=(i-1)*dt;
end
[ind,t0]=crossing(eta,t);
n_up = 0;
for i = 1:length(ind)
if eta(ind(i)+1) - eta(ind(i)) > 0
n_up = n_up+1;
ind_up(n_up) = ind(i);
t0_up(n_up) = t0(i);
end
end
fprintf(1,'no. of crossings = %g\n',length(ind))
fprintf(1,'no. of up_crossings = %g\n',n_up)
nwaves = n_up-1;
for i = 1:nwaves
wv = eta(ind_up(i):ind_up(i+1));
crest(i)=max(wv);
trough(i)=abs(min(wv));
ht(i)=crest(i)+trough(i);
end
Hav=mean(ht)
Tz=mean(diff(t0_up))
0 Comments
Sign in to comment.