Calculating the average every three months

5 ビュー (過去 30 日間)
desert_scientist90
desert_scientist90 2019 年 10 月 24 日
編集済み: Artemio Soto Breceda 2019 年 10 月 24 日
Hi all, I leaning matlab thru practice and patience, I have the following dataset with sunspot observations for 38 years. I am trying to get the average of months 12,1,2 per year. I was using the code below but I am getting the following error message. " Undefined operator '>=' for input arguments of type 'table'."
Any advise will be greatly appreciated.
IDX=data(:,3) >= 5;
fdata = data(idx,:);
iex = fdata(:,3) <= 7;
fildata = fdata(iex,:);
year = fildata(:,2);
avr = accumarray(year,fildata(:,1))./3;
idx = avr(:,1) > 0;
avr = avr(idx,1);
  4 件のコメント
desert_scientist90
desert_scientist90 2019 年 10 月 24 日
sunspot1(1:10, :)
ans =
10×3 table
Year month sunspot
____ _____ _______
1980 12 246.9
1981 1 156.6
1981 2 189.9
1981 3 196.6
1981 4 225.3
1981 5 194.7
1981 6 131.6
1981 7 205.3
1981 8 242.5
1981 9 245.3
Those are the results of that approach
Artemio Soto Breceda
Artemio Soto Breceda 2019 年 10 月 24 日
編集済み: Artemio Soto Breceda 2019 年 10 月 24 日
Ah, thanks. I hadn't seen that you included your xlsx file in the post. See my answer below.

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

採用された回答

Artemio Soto Breceda
Artemio Soto Breceda 2019 年 10 月 24 日
You have two options, to convert your table into an array with:
data_array = data{:,:};
or to use the same expression, but with curly braces, like this:
IDX = data{:,3} >= 5; % The curly braces do what you want

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by