plotting a multivariable function by colors

9 vues (au cours des 30 derniers jours)
Hamed Pouria
Hamed Pouria le 18 Août 2019
Modifié(e) : Rik le 21 Août 2019
Hello.
I want to plot this picture bot I don't know what command to useand how.

Réponses (1)

Rik
Rik le 18 Août 2019
Modifié(e) : Rik le 21 Août 2019
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 commentaire
Hamed Pouria
Hamed Pouria le 21 Août 2019
Modifié(e) : Hamed Pouria le 21 Août 2019
Thank you so much. I used surf and I got this. (still has difference)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Color and Styling dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by