I'm trying to plot a 5x5 matrix (call is a for now) composed of either +1 or -1. I want to plot this using a heat map such that a black square will represent a (-1) and a white square will represent a (+1). I think the appropriate command to should be image, however if I just do image(a) I don't get much...
Thanks in advance!
You should instead use the function IMAGESC so it scales the display of the image values to the full range of the colormap. Then you can use the functions COLORMAP and GRAY to display the image as black (-1) and white (+1):
imagesc(a);
colormap(gray);
Create a two-color colormap and offset the matrix values to fall within the colormap range:
>> image(a+1); >> colormap([0 0 0; 1 1 1]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With