필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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
Walter Roberson
Walter Roberson 2020년 9월 4일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by