필터 지우기
필터 지우기

Plotting discretized field in 2D

조회 수: 7 (최근 30일)
Spyros Polychronopoulos
Spyros Polychronopoulos 2018년 6월 12일
댓글: Anton Semechko 2018년 6월 12일
I have x,y Cartesian Coordinates and a value next to them that I would like to plot in color in the corresponding x,y.
xy = linspace(0,20,11);
x_y_value = [(combvec(xy,xy) )' rand(121,1)];
Here I would like to plot 2x2 squares at x,y (two first columns of x_y_value matrix) colored according to the value (third column of x_y_value matrix).
I am looking something like the attached image.
Thank you

채택된 답변

Anton Semechko
Anton Semechko 2018년 6월 12일
Here is an example:
x_lim=[0 20];
x=linspace(x_lim(1),x_lim(2),11);
[X,Y]=meshgrid(x);
F=randn(size(X)).*X-randn(size(X)).*Y;
figure('color','w')
imagesc(x_lim,x_lim,F)
axis equal
set(gca,'XLim',x_lim+[-1 01],'YLim',x_lim+[-1 1])
  댓글 수: 6
Spyros Polychronopoulos
Spyros Polychronopoulos 2018년 6월 12일
This is exactly what I was looking for! I have never came across bsxfun. Thank you again Anton!
Anton Semechko
Anton Semechko 2018년 6월 12일
You are welcome!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by