程序如下
clc
clear
%%
a=[1,8,3,4,5;
3,5,8,8,10];
figure
h=imagesc(a);
colormap(gray)
效果如下:
我想把上图中为8的点设置为红色显示,其他均为灰度显示。有大佬懂吗?

 採用された回答

华纳公司开户【微8785092】
华纳公司开户【微8785092】 2023 年 5 月 19 日

0 投票

NaN的话,还是替换一下比较合适,例如
clc; clear all; close all;
a=[1,NaN,3,4,5;
3,5,NaN,8,10];
b=a;
b(isnan(b)) = max(a(:))*2;
figure
h=imagesc(b);
mp=[0.1429 0.1429 0.1429
0.2857 0.2857 0.2857
0.4286 0.4286 0.4286
0.5714 0.5714 0.5714
0.7143 0.7143 0.7143
0.8571 0.8571 0.8571
1.0000 1.0000 1.0000
1.0000 0 0];
colormap(mp);
% colormap(gray);
colorbar

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!