2016-08-22 3 views
0

다음 이미지의 빨간색 패치는 수치 모델의 도메인을 보여줍니다. 녹색 패치는 지구를 보여줍니다.NaN이 아닌 NaN 값을 나타내는 imagesc

domain of the numerical model

나는 모델 도메인의 점에 대한 지구 표면 위 높이의 값으로 행렬을 만들려고합니다. 사람이 기대하는 것처럼

figure; 
imagesc(Z) 
colorbar 

Z values

사실 지점 (240)에서 값이 600 :

close all 
clear all 

%%%slope coefficient 
a=1/50; 

%%%resolution 
dx = 500; 
dz = 2.5; 

%%%define domain 
xi = 0:dx:200e3; 
zi = 0:dz:6e2; 
m=length(zi);%domain dimension 
n=length(xi);%domain dimension 

%%%max z where the slope starts 
zs = find(zi==max(zi)); 


for ii=1:n %for every x 

    zslope = -a*xi(ii)+zi(zs);%equation of the slope 

    zz(ii)=zslope; 
    if zslope>=0 %if the slope is still in the domain (z>0) 
    for jj=1:m %for every z 

     if zi(jj)>=zslope %above the slope 

     Z(jj,ii) = zi(jj)-zslope; %height above the slope 

     elseif zi(jj)<zslope %below the slope (ground) 

     Z(jj,ii)=NaN; 

     end 
    end%for on z 

    elseif zslope<0 %the slope is no longer in the domain 

     for jj=1:m %for every z 

      Z(jj,ii) = zi(jj)-zslope; %height above the slope 

     end 
    end 
end%for on x 

잘 작동하는 것 같다 :

는 다음 코드를 사용합니다.

인한 문제

문제는 작업 공간에 Z 행렬 NaN들로 가득하다 것입니다!

NaN 일 때 imagesc의 값이 NaN이 아닌 것으로 표시 될 수있는 방법은 무엇입니까? 내가 선

elseif zi(jj)<zslope %below the slope (ground) 

    Z(jj,ii)=NaN; 

을 언급하는 경우

참고

아무 문제가 없다.

답변

1

NaN은 색상 막대에서 가장 낮은 값으로 표시됩니다 (반대로). 플롯에서 NaN 값을 제거하려면 isnanAlphaData 속성을 사용하여 NaN 값을 제거 할 수 있습니다.

imagesc(Z,'AlphaData',~isnan(Z)) 
관련 문제