Plotting a colored surface in 2D

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 日

8 投票

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 日

5 投票

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 日

0 投票

syms x y y=sin(x) ezplot(x,y)
Gul Rahman Abdulrahimzai
Gul Rahman Abdulrahimzai 2022 年 11 月 18 日

0 投票

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

カテゴリ

質問済み:

2014 年 12 月 26 日

コメント済み:

2023 年 8 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by