How plot a figure like this attached figure?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have some laser beam amplitude profile and I want to plot this profiles like follow fig in matlab.
infact, I have tried this codes
% z1 and z2 are defined in my script as 500*500 matrix
r1=linspace(0,0.005,500);
r2=r1;
mesh(r1,r2,z1)
hold on
mesh(r1,r2,z2+2)
but I can not rotate and it not give what I want. I need help?
0 个评论
采纳的回答
J. Alex Lee
2020-2-2
编辑:J. Alex Lee
2020-2-2
It's because mesh expects z-data to be actual coordinates in z, but mesh (and surf) will accept a 4th argument for color
N = 500;
r1=linspace(0,0.005,N);
[X,Y] = meshgrid(r1);
figure; cla; hold on;
ax = gca;
% fig = figure;
% ax = axes(fig,'NextPlot','add');
for i = 1:10
C = rand(N); % replace with the image
Z = ones(N)*i;
% flip the order of Y and Z to get vertical slices
s = surf(ax,X,Z,Y,C,'EdgeColor','none');
end
ax.DataAspectRatio = [1,700,1] % stretch the "z"-axis view
% rotate the view
view([-65,14])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!