plot a 3d function (with three independent variable)
显示 更早的评论
I am traying to plot
in matlab like this picture! how can i do it? thank you
in matlab like this picture! how can i do it? thank you
采纳的回答
6 个评论
hi, thanks for your answer but i want it with shadows like this picture i tried this code but it wasn't like my picture
My pleasure!
I have no idea what you intend by ‘shadows’, since all that is necessary to produce them is to create a lighting effect.
Example —
N = 50;
xv = linspace(-10,10, N);
yv = linspace(-10,10, N);
zv = linspace(-10,10, N);
vfcn = @(x,y,z) 4*x.^2 + 9*y.^2 + 4*z.^2;
[Xm,Ym,Zm] = meshgrid(xv,yv,zv);
Vm = vfcn(Xm,Ym,Zm);
figure
p = patch(isosurface(Xm, Ym, Zm, Vm, 36));
isonormals(Xm,Ym,Zm,Vm,p)
p.FaceColor = 'red';
p.EdgeColor = 'none';
daspect([1 1 1])
view(3);
% axis tight
axis('equal')
camlight
lighting gouraud
grid on
hold on
plot3([-5 5], [0 0], [0 0], '-k')
plot3([0 0], [-5 5], [0 0], '-k')
plot3([0 0], [0 0], [-5 5], '-k')
hold off
text(-6, 0, 0, '$x$', 'Interpreter','latex', 'FontSize',20)
text(0, -6, 0, '$y$', 'Interpreter','latex', 'FontSize',20)
text(0, 0, 6, '$z$', 'Interpreter','latex', 'FontSize',20)

This is partially copied from the isosurface documentation.
thank you so much and how can i unfill the graph like picture?
My pleasure!
If by ‘unfill’ you mean to see inside it, add this assignment —
p.FaceAlpha = 0.75; % See Inside The Volume!
so the revised code is now —
N = 50;
xv = linspace(-10,10, N);
yv = linspace(-10,10, N);
zv = linspace(-10,10, N);
vfcn = @(x,y,z) 4*x.^2 + 9*y.^2 + 4*z.^2;
[Xm,Ym,Zm] = meshgrid(xv,yv,zv);
Vm = vfcn(Xm,Ym,Zm);
figure
p = patch(isosurface(Xm, Ym, Zm, Vm, 36));
isonormals(Xm,Ym,Zm,Vm,p)
p.FaceColor = 'red';
p.EdgeColor = 'none';
p.FaceAlpha = 0.75; % See Inside The Volume!
daspect([1 1 1])
view(3);
axis tight
camlight
lighting gouraud
grid on
hold on
plot3([-5 5], [0 0], [0 0], '-k')
plot3([0 0], [-5 5], [0 0], '-k')
plot3([0 0], [0 0], [-5 5], '-k')
hold off
text(-6, 0, 0, '$x$', 'Interpreter','latex', 'FontSize',20, 'Horiz','center', 'Vert','middle')
text(0, -6, 0, '$y$', 'Interpreter','latex', 'FontSize',20, 'Horiz','center', 'Vert','middle')
text(0, 0, 6, '$z$', 'Interpreter','latex', 'FontSize',20, 'Horiz','center', 'Vert','middle')

Change that value to something between 0 (fully transparent) and 1 (not at all transparent) to get the result you want.
.
As always, my pleasure!
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Volume Visualization 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
