Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Colormap Grid

Asked by An on 30 Nov 2011

Hi, I am new user of MATLAB and especially new with graphic. I am working on a visualization project and need some ideas how to start. Basically, I am having data for a whole bunch of vectors and they are divided into rows. So say 1000 vectors then every 10 of them start on the same row. I am trying to figure out a way to plot a grid on the background of all these vectors. Each square containing the vector will have a certain color that relate to the magnitude of the vector. I already plot the vectors using quiver but do not know how to start with the grid and colormap. Sorry if i sound confusing because I kinda am. Thank you, An




No products are associated with this question.

2 Answers

Answer by Naz on 30 Nov 2011

I would make a 2D matrix with 1000 rows and 10 columns and the color in each of 1000*10 squares would represent the relative magnitude:



An on 30 Nov 2011

So do I have to normalize all the magnitude to use this function?
Can I use it to create rectangle grid of different width or length instead of square grid since i think the y coordinate of my data is non-uniform.
Thank you so much,

Naz on 30 Nov 2011

imagesc function is for image scale as far as I know, so it should normalize the matrix itself, however, you can normalize it yourself to make sure all is good.
The second question is not clear to me.

An on 1 Dec 2011

thank you

Answer by Image Analyst on 1 Dec 2011

Just load your numbers into a rectangular 2D matrix. Offset the vectors to start at whatever row or column in the 2D matrix you want. You can then display it with image(), imshow(), or imagesc(). Use colormap if you need to to fix up the colors to what you want. To see grid lines you're going to have to replicate your vectors into several lines if you want a grid line between your rows to be a single line of pixels. For example one row goes to 8 rows and there is a single row of black (0) in between that row and the others so that you'll have black outlines around your main row. You'll also have to have a really big image, like 4000 rows or more otherwise you won't have black gridlines between your rows. That means you'll have to have it zoomed in because your monitor is probably not much more than 1000 lines. Write back if you need a demo.

1 Comment

An on 1 Dec 2011

Could you please help me with a demo. I currently have the x,y coordinate and also the magnitude of the vector.
really appreciate it

Image Analyst

Contact us