Convert a integer matrix to a red and blue colored matrix
1 回表示 (過去 30 日間)
古いコメントを表示
I have the following matrix A = [-1 1 1; 1 -1 1; -1 -1 -1], I want to convert it to a colored matrix with cells corresponding to 1 colored red and -1 colored blue. Something like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1121425/image.jpeg)
How do I do that in matlab?
0 件のコメント
採用された回答
Chunru
2022 年 9 月 10 日
A = [-1 1 1; 1 -1 1; -1 -1 -1]
imagesc(A);
% select a colormap
cmap = hsv(8); % based on hsv
cmap = cmap([5 1], :); % choose color 5 and 1
colormap(cmap);
colorbar
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!