How to plot these types of plot?

1 view (last 30 days)
Athira T Das
Athira T Das on 20 Jul 2022
Commented: Torsten on 25 Jul 2022

Accepted Answer

Mathieu NOE
Mathieu NOE on 20 Jul 2022
hello
see my demo below. Change the profile and data scaling accorsing to your needs
hope it helps
figure(3) plot :
code :
%% create the mexican hat 3D plot
% 2D line (profile along a radius)
r = linspace(0,1,100); % radius
zs = exp(-r.^2*16); % profile (along a radius)
figure(1);
plot(r,zs);
% create the 3D plot
theta = linspace(0,2*pi,length(r));
[x,y]=pol2cart(theta, r'); % NB the transposed r to create x, y as matrices and not just vectors !!
zsr=zs'*ones(1,length(r));
figure(2);
s = surf(x,y,zsr);
s.EdgeColor = 'none';
view([0 90]);
axis('equal');
% colormap('gray');
colormap('hot');
colorbar('vert');
% interpolation on a 1024 x 1024 square grid
ll = max(r) / sqrt(2);
m = linspace(-ll,ll,1024);
[Xq,Yq] = meshgrid(m,m);
zq = griddata(x,y,zsr,Xq,Yq);
figure(3);
s = surf(Xq,Yq,zq);
s.EdgeColor = 'none';
view([0 90]);
axis('equal');
% colormap('gray');
colormap('hot');
colorbar('vert');
xlim([-ll ll]);
ylim([-ll ll]);
  2 Comments
Athira T Das
Athira T Das on 25 Jul 2022
@Mathieu NOEwhat's the name of this type of plot?
Torsten
Torsten on 25 Jul 2022
surface plots
contour plots

Sign in to comment.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!