OK, I am still getting the hang of MATLAB. I have two files in different format.
One Excel file. data1.xls
, size= 86400 X 62.
It looks like:
Date/Time par1 par2 par3 par4 par5 par6 par6 par7 par8 par9
08/02/09 00:06:45 0 3 27 9.9 -133.2 0 0 0 1 0
Another file, data2.csv
, size = 144 X 27. (If nothing is missing.)
It looks like:
date time P01 P02 P03 P04 P05 P06 P07 P08 P09 P10 P11
8/16/2009 0:00 51 45 46 54 53 52 524 5 399 89 78
Now I am using
Data10minAvg = mean(reshape(Data,300,144,62));
to get the 10 min average of the first Excel file. Now I need to match up that file I am making above with the .csv file. The problem is many timestamps are missing in the .csv file.
How do I make data2.csv
into a file of size 144 X 27, replacing the missing datestamps by rows of zero?
It will really help me than compare data1.xls file with newdata2.csv.
Update
Hi This is Paul. Thanks a lot Geodesic. I do not know how to edit so i could not have written my whole files. You understood the question perfectly.
But now when i run your code , it generates a file of length 377 X 11 when i use timediff(i) >10 as i want 10 min intervals , so i should not have more than 144 as my file length. your code is quite complicated for me i was using
fid = fopen('data2.csv', 'rt');
topLine = fgets(fid);
data = textscan(fid, '%s %f %f %f %f %f%f%f %f %f %f %f%f%f %f %f %f %f%f%f %f %f %f %f%f%f %f %f ' ,.... 'Delimiter',',', 'CollectOutput',1, 'HeaderLines',1);
fclose(fid);
p= [datenum(data{1}) data{2}];
for n=1:127 % this file was of length 127
s=datevec(p(n,1)); Hour= s(1,4) min=s(1,5)
nTime(n,:)=60*Hour+min; end
to get my times
Can you help me understand your last for loop so i can use it.
my final file has to be of length 144 X 11 ( columns vary but i can change that ) but rows have to to 144
**Just tried using your code timeDiff = round(diff(datenum(time)*24*6)); it gave me 143 rows , much closer to what i want. **
also all other values are getting rounded, anyway to stop it?
Thanks a ton.