How to plot a matrix ?

I have a 100x6 matrix. in which first and second columns represent x coordinate and y coordinate respectively. I want to plot a square of 0.5x0.5 dimension on that coordinates (as a representation).[i.e. in plotting a matrix, how to visually represent every cell as a square of dimension 0.5 by 0.5 having coordinates as per the first and second columns resp.] how to do ?

Respuestas (1)

Walter Roberson
Walter Roberson el 6 de Mzo. de 2017

0 votos

scatter(YourMatrix(:,1), YourMatrix(:,2))

5 comentarios

h b
h b el 6 de Mzo. de 2017
here is it possible to replace circle markers with square of dimension 0.5 by 0.5.
Walter Roberson
Walter Roberson el 6 de Mzo. de 2017
Unfortunately your units are not clear, so I show how to work it out.
marker_width_cm = 0.5;
marker_width_inch = marker_width_cm / 2.54;
marker_width_points = marker_with_inch * 72;
marker_area_sq_points = marker_width_points .^ 2;
scatter(YourMatrix(:,1), YourMatrix(:,2), marker_area_sq_points, 's', 'filled')
You can leave out the 'filled' if you want open squares.
You might also want to adjust the axes 'Units' and 'Position' properties and make DataAspectRatio [1 1 1] if you want the graph to be a particular size.
h b
h b el 6 de Mzo. de 2017
My units are in meters . Here How to set the axis units to meters?
marker_width_cm = 0.005;
marker_width_m = marker_width_cm * 100;
marker_width_points = marker_width_m * 72;
marker_area_sq_points = marker_width_points .^ 2;
h b
h b el 6 de Mzo. de 2017
Editada: h b el 6 de Mzo. de 2017
For the code mentioned above, also Is there a way to avoid gaps between two successive square cells as in attached figure. ("In normal view", blocks appear very closely spaced, not visible: whereas in "zoomed in" view the gaps appear) please provide solution.
Walter Roberson
Walter Roberson el 6 de Mzo. de 2017
Editada: Walter Roberson el 6 de Mzo. de 2017
For meters, you would use
marker_width_cm = 50;
However, the tallest screen I can borrow is only about 37 cm tall, which would not fit even one of the squares.
The code I gave should, in theory, draw "life size" -- that is, you ask for half meter squares and it would try to draw a square that was physically half a meter wide. It would also remain that wide no matter how much you zoomed the plot in or out, since that's what you asked for, that the squares be half a meter wide.
I think you should reconsider your size requirements.
If you were to put a measuring tape on the screen, would the drawn squares have to be a certain physical measurement? Or do they only have to assume a particular physical measurement went sent to a flatbed plotter? Or is this about drawings in which the labels and feedback information represent something that is 1/2 meter on a side?

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

h b
el 6 de Mzo. de 2017

Editada:

el 6 de Mzo. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by