필터 지우기
필터 지우기

How do I take average of lat long data of a NetCDF file? Facing problem!

조회 수: 3 (최근 30일)
Lavnish Gupta
Lavnish Gupta 2018년 5월 21일
댓글: KSSV 2018년 5월 21일
I am having a NetCDF file with sst variable. I have an array named sstdata which is a 1440x168x289 double. (long x lat x time). I need to take domain average of sstdata so that it only varies with time to get a average plot w.r.t time. I have written the following code:
k=0;
for m=drange(1:1440)
for n=drange(1:168)
k=k+sstdata(m,n,:);
end
end
k=k./1440;
k=k./168;
But I am getting only a 1 x 1 x 289 double which only has NaN and zeros as its values. Is there anything wrong with the code? Please help!

답변 (1개)

KSSV
KSSV 2018년 5월 21일
Read about mean. You read the whole variable of size 1440x168x289 into workspace and use mean. mean accepts dimensions...you have to use mean on third dimension.
sst = ncread(filename,'variable') ; %read sst data here
iwant = mean(sst,3) ;
  댓글 수: 4
Lavnish Gupta
Lavnish Gupta 2018년 5월 21일
Yes! For this I did
iwant=mean(sst,2);
iwant2=mean(iwant,1);
Is this right?
KSSV
KSSV 2018년 5월 21일
That's fine....you can use:
iwant = mean(mean(A)) ;

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

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by