Mean calculation from nxm matrices using nxm index matlab

조회 수: 1 (최근 30일)
Abaye Getahun Abebe
Abaye Getahun Abebe 2018년 3월 12일
답변: Andrei Bobrov 2018년 3월 15일
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
Stephen23
Stephen23 2018년 3월 12일
@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.

댓글을 달려면 로그인하십시오.

답변 (2개)

Prajit T R
Prajit T R 2018년 3월 15일
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

Andrei Bobrov
Andrei Bobrov 2018년 3월 15일
out = [(1:12)',accumarray(Month_data(:),flow_data(:),[],@mean)];

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by