Hello,
I am trying to read nc file and it contains values (-177.6600, -177.6500, -177.6300, -177.5900, -177.5700). I want to assign NaN to all these values (there is a huge number of these values).I tried the following code but it didn't remove the maximum value i.e., -177.5700.
Temp = ncread('G\01.06.17\NC_H08_20170601_0500_L2CLP010_FLDK.02401_02401.nc', 'Temperature');
Temp(Temp<=-177.5700)= NaN;
Kindly help.
Thank you.

댓글 수: 4

KSSV
KSSV 2021년 3월 1일
What have you tried is correct. What made you to tell that the value is not replaced with NaN? What is size of Temp?
IMC
IMC 2021년 3월 1일
Size of temp is 2401*2401
This is the result after running code. -177.5700 values are still present.
Try:
tol = 10^-3 ;
Temp(Temp<=-(177.5700+tol))= NaN;
IMC
IMC 2021년 3월 1일
Unfortunately, It didn't work.

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

 채택된 답변

David Hill
David Hill 2021년 3월 1일

0 개 추천

You might try rounding to 4 decimal places first
Temp=round(Temp,4);
Temp(ismember(Temp,[-177.6600, -177.6500, -177.6300, -177.5900, -177.5700]))=nan;

댓글 수: 1

IMC
IMC 2021년 3월 1일
Thanks David!. It tried using your lines of code and it worked.

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

추가 답변 (1개)

Allen
Allen 2021년 3월 1일

0 개 추천

A slightly more simple approach:
Temp(round(Temp,4)<=-177.57)= NaN;

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

IMC
2021년 3월 1일

댓글:

IMC
2021년 3월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by