Calculating the average every three months
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!