Convert a integer matrix to a red and blue colored matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Debadipto
am 10 Sep. 2022
Kommentiert: Debadipto
am 10 Sep. 2022
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:
How do I do that in matlab?
0 Kommentare
Akzeptierte Antwort
Chunru
am 10 Sep. 2022
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Colormaps finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!