Effacer les filtres
Effacer les filtres

Assign colour to grid cells of arbitrary length given the index of the cell

1 vue (au cours des 30 derniers jours)
Josyula Gopala Krishna
Josyula Gopala Krishna le 4 Sep 2020
Hi i am trying to recreate the following image, in this image each grid is a 2x2 square and the color represents the probability of occupancy.
I have the index of the cell corner example matrix c = [1 1; 2 3; 4 5] and values corresponding to those cells logprob = [0.5, 0.3, 0.8]
I have tried using imagesc still i am not able to apply it to achieve the desired result, since it doesn't have a cell width property. any help is greatly appreciated thank you.
  1 commentaire
Walter Roberson
Walter Roberson le 4 Sep 2020
You can pass XData and YData properties to imagesc() in order to control the positions of the data pixels in data coordinates. By careful choice of axes Position and axes Units properties, and using the XData and YData properties, you can control the exact number of pixels that an image will take on the display.
However:
  1. Be careful: XData and YData correspond to coordinates of the centers of the boundary pixels, not to the edges. You need to allow space for half a pixel relative to the coordinates given
  2. With high enough resolution displays, on Windows MATLAB maps 100 "pixels" to 1 inch, and on Mac MATLAB maps 72 "pixels" to 1 inch. Determining the correct adjustment for physical pixels can be a nuisance.
  3. data pixels cannot be different sizes when this is used. If you need data pixels to be different sizes, see warp()
... But I suspect that is not what you are talking about. I suspect what you are looking for is painting the grid. "grid on", and look at XTicks and XMinorTicks to control grid locations.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by