Plotting a colored surface in 2D

조회 수: 126 (최근 30일)
Johnson
Johnson 2014년 12월 26일
댓글: Yinghui Hu 2023년 8월 18일
Dear experts,
I have two vectors: x and y, and a function u(x,y) representing the temperature in the point (x,y). I want to see different temperatures as different colors, in the XY plane (see an example in the attached picture). i.e.- u will be given as color in the XY plane.
Will someone please help me understand what is the appropriate method to use in order to obtain such a plot?
Thanks in advance

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 12월 26일
Look at this example
x=1:0.1:4
y=1:0.1:4
[X,Y]=meshgrid(x,y)
Z=sin(X).^2+cos(Y).^2
surf(X,Y,Z)
view(2)
  댓글 수: 2
Johnson
Johnson 2014년 12월 26일
Thanks a lot Azzi !
Ahmad Asghar
Ahmad Asghar 2018년 11월 5일
View(2) ignores the last row and col. Any idea how to avoid that? Appending a zero row and col is not working :)

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

추가 답변 (3개)

Abdullah Talib
Abdullah Talib 2018년 11월 14일
you can also use
imagesc(x,y,u); colormap jet; axis xy;
  댓글 수: 2
yogendra jaiswara
yogendra jaiswara 2022년 10월 2일
Nice
Yinghui Hu
Yinghui Hu 2023년 8월 18일
it is a great help. Just what I would like to have!

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


Vijendra Singh
Vijendra Singh 2020년 12월 21일
syms x y y=sin(x) ezplot(x,y)

Gul Rahman Abdulrahimzai
Gul Rahman Abdulrahimzai 2022년 11월 18일
0 <= x <= 1
3 <= y <= 4
z=a(〖xy)〗^0.7 cos⁡(ax)
Create plot. Use function surf
a=input ('a = ');
[x,y]= meshgrid(0:0.1:1,3:3.5:4);
z = a*exp(x*y)^0.7*cos(x*a);
surf(x,y,z);
What is the problem with this model plz

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by