aggregating profiles of data
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ashehad Ali
el 11 de Jun. de 2015
Comentada: Ashehad Ali
el 24 de Jun. de 2015
Hi there,
I would like to aggregate these three profiles of data-sets (HA01.csv, HA02.csv, HA03.csv) in matlab by determining the means so that the "new data-set" will have the same structure (i.e. the no. of rows and no. of columns as either of the three profiles and that the "new data-set" would contain means for the variables: SW1,SW2,SW3,SW4,SW5,SW6,SW7. That is, in the new-data set, for Hr=0, SW1= mean(x1,x2,x3), where x1 is the SW1 entry in HA01.csv when Hr=0, x2 is the SW1 entry in HA02.csv when Hr=0, where x3 is the SW1 entry in HA03.csv when Hr=0. The unknown values are reported in the data as -9999 or -9998 and when reporting the means, if at least one value is either -9999 or -9998, then the mean can be either -9999 or -9998.
I'm attaching the three data files. Would appreciate your feedback.
Ashehad
0 comentarios
Respuesta aceptada
Aarti Ghatkesar
el 16 de Jun. de 2015
Hi Asheshad
The following code would do the operation of finding the mean for the columns SW1 to SW7 and write to a new file named 'newfile.csv'. Note that 'csvread' or 'dlmread' cannot write column headers.You can use the submission here to write column headers to a csvfile
numofcols=10;
numofrows=25;
ID=csvread('HA01.csv',1,0,[1,0,24,0])
Num=csvread('HA01.csv',1,1,[1,1,24,1])
Hr=csvread('HA01.csv',1,2,[1,2,24,2])
Final=[ID,Num,Hr];
for i=4:1:numofcols
SW_file1=csvread('HA01.csv',1,i-1,[1,i-1,numofrows-1,i-1])
SW_file2=csvread('HA02.csv',1,i-1,[1,i-1,numofrows-1,i-1])
SW_file3=csvread('HA03.csv',1,i-1,[1,i-1,numofrows-1,i-1])
SW=(SW_file1+SW_file2+SW_file3)./3
Final=[Final,SW];
end
csvwrite('newfile.csv',Final,1,0)
Hope it helps
Más respuestas (0)
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!