下图中的红色补丁显示了数值模型的域。绿色斑块显示地球。
我想创建一个矩阵,其高度值高于地球表面,用于模型域中的点。
我使用以下代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.test_controller">
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>// add this
<activity android:name=".SettingsActivity" />
这似乎工作正常:
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
实际上,240点的值是人们期望的600.
问题
问题是在工作区中figure;
imagesc(Z)
colorbar
矩阵充满了Z
s!
NaN
时,imagesc
如何显示NaN
值?
注意
如果我评论这些行
NaN
没有问题。
答案 0 :(得分:1)
NaN
显示为colorbar中的最低值(相反)。如果要从图中删除NaN值,可以使用isnan
和AlphaData
属性来执行此操作。
imagesc(Z,'AlphaData',~isnan(Z))