matlab的一个隐函数的画图出现错误,x=-5:0.1:5;y=5:0.1:5;z=-5:0.1:5; [x,y,z]=meshgrid(x,y,z); f=((x^2+(9/4)y^2+z^2-1)^3-x^2z^3-(9/80)y^2z^3); p=patch(isosurface(x,y,z,f,0)); set(p,'FaceColor','red','EdgeColor','none'); daspect([1 1 1])vie
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 09:21:45
matlab的一个隐函数的画图出现错误,x=-5:0.1:5;y=5:0.1:5;z=-5:0.1:5; [x,y,z]=meshgrid(x,y,z); f=((x^2+(9/4)y^2+z^2-1)^3-x^2z^3-(9/80)y^2z^3); p=patch(isosurface(x,y,z,f,0)); set(p,'FaceColor','red','EdgeColor','none'); daspect([1 1 1])vie
matlab的一个隐函数的画图出现错误,
x=-5:0.1:5;y=5:0.1:5;z=-5:0.1:5;
[x,y,z]=meshgrid(x,y,z);
f=((x^2+(9/4)y^2+z^2-1)^3-x^2z^3-(9/80)y^2z^3);
p=patch(isosurface(x,y,z,f,0));
set(p,'FaceColor','red','EdgeColor','none');
daspect([1 1 1])
view(3)
camlight; lighting phong
总是出现:
f=((x^2+(9/4)y^2+z^2-1)^3-x^2z^3-(9/80)y^2z^3);
|
Error:Missing variable or function.
matlab的一个隐函数的画图出现错误,x=-5:0.1:5;y=5:0.1:5;z=-5:0.1:5; [x,y,z]=meshgrid(x,y,z); f=((x^2+(9/4)y^2+z^2-1)^3-x^2z^3-(9/80)y^2z^3); p=patch(isosurface(x,y,z,f,0)); set(p,'FaceColor','red','EdgeColor','none'); daspect([1 1 1])vie
I did this before, so just give you the codes I wrote, try this:
(you should use .^, .* and ./ instead of ^, * and / because you want to do operations on every element, not the matrix or vector.
%%This file creates a 3-d red heart with an equation
[x,y,z]=meshgrid(linspace(-3,3,120));
f=(x.^2+(9*y.^2)./4+z.^2-1).^3-((9*y.^2).*(z.^3))./80-(x.^2).*(z.^3);
p=patch(isosurface(x,y,z,f,0));
set(p,'FaceColor','r')
grid on
daspect([1 1 1])
view(3)
camlight('right')
camlight('left')
camlight('headlight')
lighting phong
xlabel('X')
ylabel('Y')
zlabel('Z')
title('Heart of Math')