how to change values within an array to NaN

조회 수: 24 (최근 30일)
Harald von der Osten
Harald von der Osten 2021년 1월 18일
댓글: Harald von der Osten 2021년 1월 18일
loading xyz-data into Matlab and interpolate that scattered data like this:
load f56.dat
x=f56(:,1); y=f56(:,2); z=f56(:,3);
F=scatteredInterpolant(x,y,z);
[xn yn]=meshgrid(min(x):0.01:max(x),min(y):0.01:max(y));
zn=F(xy,yn);
gives me 1950 values in x and 4000 in y.
Because of a region of bad data I would like to set that region to NaN for further processing. How can I set 1280 <= x <= 1950 and 3025 <= y <= 4000 to NaN ?
Thanks a lot.

채택된 답변

Matt J
Matt J 2021년 1월 18일
편집: Matt J 2021년 1월 18일
zn = F(xn,yn);
bad = (1280 <= xn & xn<=1950) & (3025 <= yn & yn <= 4000) ;
zn(bad)=nan;
  댓글 수: 1
Harald von der Osten
Harald von der Osten 2021년 1월 18일
oh...much easier than I thought it would be...thanks a lot :-)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by