资源描述:
《在notebook里使用matlab作图.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、1安装word安装matlab2.在matalb的commond窗口输入notebook–setup然后按回车3.输入notebook即可启动word4,输入matlab命令如pi然后选中(单行可以不选中)后按下alt+D组合键,变绿色,如下所示5.再按下ctrl+Enter键,执行,出现蓝色结果或者图片。如下所示以下介绍几个matlab基本的操作命令,然后重点写了几个绘图命令(绿色为输入,蓝色为输出)pians=3.1416vpa(pi,100)ans=3.14159265358979323846264338327950288419716939937510582097494459230
2、7816406286208998628034825342117068symsxf;f=@(x)100*(x(2)-x(1)^2)+(1-x(1))^2f=@(x)100*(x(2)-x(1)^2)+(1-x(1))^2x=[12],f(x)x=12ans=100y=[21];f(y)ans=-299x=linspace(0,2*pi,30);y=sin(x);z=cos(x);plot(x,y,'r',x,z,'go')ezplot('sin(x)',[0,5*pi])ezplot('cos(t)^3','sin(t)^3',[0,2*pi])ezplot('exp(x)+sin(x*y
3、)',[-2,0.5,0,2])myfun2=@(x)exp(2.*x)+sin(3.*x.^2)myfun2=@(x)exp(2.*x)+sin(3.*x.^2)plot(-1:0.01:2,myfun2(-1:0.01:2))fplot(myfun2,[-1,2]);fplot('tanh',[-2,2])sn=@(x)sin(1./x);fplot(sn,[0.01,0.1])fplot('[tanh(x),sin(x),cos(x)]',2*pi*[-11])x=logspace(-1,2);loglog(x,exp(x),'-s')gridont=0:pi/50:10*pi;p
4、lot3(sin(t),cos(t),t)rotate3dx=-3:0.1:3;y=1:0.1:5;[X,Y]=meshgrid(x,y);Z=(X+Y).^2;surf(X,Y,Z)shadingflatx=-3:0.1:3;y=1:0.1:5;[X,Y]=meshgrid(x,y);Z=(X+Y).^2;mesh(X,Y,Z)[X,Y]=meshgrid(-3:.125:3);Z=peaks(X,Y);meshz(X,Y,Z)x=linspace(0,2*pi,30);y=sin(x);plot(x,y)xlabel('自变量X')ylabel('函数Y')title('示意图')g
5、ridonx=linspace(0,2*pi,30);y=sin(x);z=cos(x);plot(x,y,x,z)gtext('sin(x)');gtext('cos(x)')x=linspace(0,2*pi,30);y=sin(x);z=cos(x);plot(x,z,':')holdonplot(x,y)x=linspace(0,2*pi,100);y=sin(x);z=cos(x);plot(x,y);title('sin(x)')figure(2);plot(x,z);title('cos(x)');x=linspace(0,2*pi,100);y=sin(x);z=cos(
6、x);a=sin(x).*cos(x);b=sin(x)./(cos(x)+eps);subplot(2,2,1);plot(x,y),title('sin(x)')subplot(2,2,2);plot(x,z),title('cos(x)')subplot(2,2,3);plot(x,a),title('sin(x)cos(x)')subplot(2,2,4);plot(x,b),title('sin(x)/cos(x)')clear;clc;clf;x=linspace(0,2*pi,30);y=sin(x);plot(x,y)zoomonx=-3:0.1:3;y=1:0.1:5;
7、[X,Y]=meshgrid(x,y);Z=(X+Y).^2;subplot(2,2,1),mesh(X,Y,Z),subplot(2,2,2),mesh(X,Y,Z),view(50,-34)subplot(2,2,3),mesh(X,Y,Z),view(-60,70)subplot(2,2,4),mesh(X,Y,Z),view([0,1,1])closeall;[x,y,z]=peaks(30);surf(x,y,z)axis