# How to plot these types of plot?

1 view (last 30 days)
Athira T Das on 20 Jul 2022
Commented: Torsten on 25 Jul 2022 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 CommentsShowHide 1 older comment
Torsten on 25 Jul 2022
surface plots
contour plots