Averaging Matrix and store it in a new matrix

2 次查看(过去 30 天)
This is my coding for the result. I want to show my result as the raster data cell that showed in picture 1. Any idea how to do so?
  4 个评论
Rik
Rik 2020-5-16
You can't show colors like that in the command window, you will have to use a figure.
carmen how
carmen how 2020-5-16
Ya, but I have tried a lot of method, but i couldnt show the values inside the grid

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2020-5-16
A = rand(10) ;
[m,n] = size(A) ;
[X,Y] = meshgrid(linspace(0.5,(m-0.5),m),linspace(0.5,(n-0.5),n)) ;
t = A(:) ;
pcolor(A) ;
hold on
text(X(:),Y(:),num2str(t),'color','w')
  4 个评论
carmen how
carmen how 2020-5-17
the result went upside down. The row that supposely to be row 1 has become last row in the grid.
Rik
Rik 2020-5-17
Then you should flip the order of Y. You can either modify the linspace call, or use flipud. The reason for this is that the convention for image is that the origin of the coordinates is the upper left corner, not the lower left.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by