MATLAB Answers

0

How can I plot a matrix as a colored grid?

Asked by Samuel Alonso on 18 Mar 2017
Latest activity Answered by Walter Roberson
on 19 Mar 2017
Hello,
I've been hitting hard at this for a while, but haven't been able to achieve it. I have a matrix whose values range from 0 to 300. I'd like to plot this matrix as a colored grid, where the Hue angle is given by the element of the matrix at that point, while keeping luminosity and saturation constant. How can I do this in MATLAB?

  0 Comments

Sign in to comment.

2 Answers

Answer by Walter Roberson
on 19 Mar 2017

H = double(YourMatrix)/360;
hsv = H;
hsv(:,:,2) = TheConstantStaturation;
hsv(:,:,3) = TheConstantValue;
rgb = hsv2rgb(hsv);
image(rgb); %or imshow(rgb)

  0 Comments

Sign in to comment.


Answer by Florian
on 19 Mar 2017

Is the function pcolor maybe what you are looking at?

  0 Comments

Sign in to comment.