How do I use a AVERAGEIFS statement of excel within a range for multiple data of irregular intervals in matlab?

1 回表示 (過去 30 日間)
Manasi
Manasi 2019 年 3 月 15 日
編集済み: Matt J 2019 年 3 月 18 日
I am attaching an excel sheet in here, where I have basically two columns of multiple data, i.e. altitude (column A) and temperature (column B). The altitude is in irregualer intervals from 0 to 150 m and for each value of altitude, there is a corresponding temperature value. I have created another altitude range column at a fixed 25m altitude like, [0, 25, 50, 75, 100, 125, 150]. Now, I need the average of temperature at all altitudes within the ranges 0 - 25m, 25 - 50m, 50 - 75m....and so on. So, what shoud I use obtain the result? As there are random number of datas within 0- 25 or 25 - 50, 50- 75...and so on....

回答 (1 件)

Matt J
Matt J 2019 年 3 月 15 日
編集済み: Matt J 2019 年 3 月 15 日
Something like this would do it,
groups=discretize(altitudes,ranges);
averages=splitapply(@mean, temperature,groups);
  1 件のコメント
Manasi
Manasi 2019 年 3 月 18 日
編集済み: Matt J 2019 年 3 月 18 日
Thank you very much for your replying to my problem. However, there was some issue while using your formula. The problem was solved using the following:
I = 1;
a = 1;
for i = 0:25:150
x = find(AVGIF_trial.xlsx(1:end,1)<=i);
x1 = max(x);
New_file = AVGIF_trial.xlsx(1:x1,2);
ultimate_file(a,1) = mean(New_file(I:end,1));
a=a+1;
clear New_file;
clear x;
I = x1+1
end

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by