>> x=0:0.1*pi:2*pi;%%对x赋值
>> y=sin(x);%%计算y的值
>> plot(x,y);grid on;%%利用该函数对x,y进行画图
matlab自带的画二维图的函数,plot,如你要想画y=x^2的图的话,直接在命令行输入
y=x^2
plot(x,y)就可以了。
I did this before, so just give you the codes I wrote, try this:
%%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')