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 CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by