plotting a multivariable function by colors

1 回表示 (過去 30 日間)
Hamed Pouria
Hamed Pouria 2019 年 8 月 18 日
編集済み: Rik 2019 年 8 月 21 日
Hello.
I want to plot this picture bot I don't know what command to useand how.

回答 (1 件)

Rik
Rik 2019 年 8 月 18 日
編集済み: Rik 2019 年 8 月 21 日
You can use the surf function (and set the view so you look from above), or use ind2rgb to apply a colormap.
Edit:
The code below should give you an idea of how to get your desired result.
%retrieve the x,y,z information from the surf
f=openfig('1.fig');
ax=findobj(get(f,'Children'),'type','axes');
S=findobj(get(ax,'Children'),'type','Surface');
x=get(S,'XData');
y=get(S,'YData');
z=get(S,'ZData');
z_backup=z;
close all%close all currently opened figures (use only during debugging)
%% option 1: using surf
%replace inf and -inf by edge values for a more pretty plot
z(isinf(z) & z>0)=max(z(~isinf(z)));
z(isinf(z) & z<0)=min(z(~isinf(z)));
figure
surf(x,y,z,'EdgeColor','none')
view(0,90)
axis([min(x) max(x) min(y) max(y)])
%% option 2: using ind2rgb
%define a colormap
map=colormap('hot');
z=z_backup;%restore z
%scale z-data so it is an indexed image
L=~( isinf(z(:)) | isnan(z(:)) );
range=[min(z(L)) max(z(L))];
z=(z-range(1))/(range(2)-range(1));
z=ceil(z*size(map,1));
IM=ind2rgb(z,map);
IM=rot90(IM,2);%account for different directional convention
%show image
figure
imshow(IM)
  1 件のコメント
Hamed Pouria
Hamed Pouria 2019 年 8 月 21 日
編集済み: Hamed Pouria 2019 年 8 月 21 日
Thank you so much. I used surf and I got this. (still has difference)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBlue についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by