Oh no! A(A==0)=NaN is turning my matrix into all zeros!!

조회 수: 2 (최근 30일)
Kate
Kate 2013년 7월 12일
Okay, I'm feeling like an idiot, what on earth could I be doing wrong?
>> whos KoppenDsb_airT
Name Size Bytes Class Attributes
KoppenDsb_airT 360x720x361 374284800 single
>> min(min(KoppenDsb_airT))
ans(:,:,1) =
-26.5479
ans(:,:,2) =
-23.5349
ans(:,:,3) =
-22.6819
ans(:,:,4) =
-17.3890
ans(:,:,5) =
-12.0117
ans(:,:,6) =
-8.7705
ans(:,:,7) =
-5.3165
ans(:,:,8) =
0
ans(:,:,9) =
0
etc...
KoppenDsb_airT(KoppenDsa_airT==0)= nan;
>> min(min(KoppenDsb_airT))
ans(:,:,1) =
0
ans(:,:,2) =
0
ans(:,:,3) =
0
ans(:,:,4) =
0
ans(:,:,5) =
0
ans(:,:,6) =
0
ans(:,:,7) =
0
ans(:,:,8) =
0
ans(:,:,9) =
0
etc...
Any idea what I'm doing wrong? Thanks!

채택된 답변

the cyclist
the cyclist 2013년 7월 12일
편집: the cyclist 2013년 7월 12일
I think you may be mixing up your variables
KoppenDsa_airT
and
KoppenDsb_airT
Still, the result is puzzling to me.
Is the array the same shape after that operation?
  댓글 수: 3
Kate
Kate 2013년 7월 12일
Another question: I'm trying to look at my whole KoppenDsb (monthly data) over my 30 year climate period.
KoppenDsb_airT(KoppenDsb_airT==0)= nan;
Dsb_airT_climatology=mean(reshape(KoppenDsb_airT,[],361),1);
but now my min and max are NaN's. Is there a better way to do this?
Matt Kindig
Matt Kindig 2013년 7월 12일
If you have the Statistics toolbox installed, you can you nanmean() to take the mean and ignore NaN's.
doc nanmean

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

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by