Mean calculation from nxm matrices using nxm index matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have daily flow data from 400 gauging stations.The length of the flow data is about 20 years. I want to calculate 20-yrs averages flow for each month of the year using for-loop in matlab. Please see the attachment. I just want to average flow-data(flow_data.PNG) using the corresponding identical index value (index.PNG).
thanks
1 comentario
Stephen23
el 12 de Mzo. de 2018
@Abaye Getahun Abebe: screenshots of data are useless for us. We cannot import screenshots of data, we cannot search screenshots of data, we cannot test our code on screenshots of data.
If you want help with this then delete the screen shots and upload some sample data files.
Respuestas (2)
Prajit T R
el 15 de Mzo. de 2018
Hi Abaye I understand that you wish to obtain the monthly mean flow for the data you have provided. Assuming that Month_data.mat contains the information of month v/s gauging station, I have written a code to find the average flow for each month. I'm not sure if this is what you are looking for, but hope this helps.
load('flow_data.mat');
load('Month_data.mat');
mean_month=[];
for i=1:12
cur_month=find(Month_data==i);
mean_month(end+1)=mean(flow_data(cur_month));
end
mean_month
The variable cur_month returns indices of all occurrences of the particular month, and we filter the flow data using these indices to obtain the average.
Cheers
0 comentarios
Andrei Bobrov
el 15 de Mzo. de 2018
out = [(1:12)',accumarray(Month_data(:),flow_data(:),[],@mean)];
0 comentarios
Ver también
Categorías
Más información sobre Characters and Strings 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!