msww.net
当前位置:首页 >> MAtlAB中,画了个sin(x)图,holD,又画了个Cos(x)图,holD,想画出sin(x >>

MAtlAB中,画了个sin(x)图,holD,又画了个Cos(x)图,holD,想画出sin(x

clc,clear;x=0:0.01:2*pi;y1=sin(x);y2=cos(x);y3=sin(x)-cos(x);plot(x,y1,'r');hold onplot(x,y2,'y');hold onplot(x,y3,'b');legend('sin(x)','cos(x)','sin(x)-cos(x)')

clear all; clc; x = 0:0.1:2*pi; y1 = sin(x); y2 = cos(x); plot(x,y1,'-or',x,y2,'--*b'); xlabel('x'); ylabel('y'); leg=char('正弦函数','余弦函数'); legend(leg); title('正余弦函数图像');

ezplot('cos(x)-x*sin(x)') %画出图像fzero('cos(x)-x*sin(x)',x0) %x0是你根据图像猜的根,函数返回该值附近的零点ezplot默认的范围是[-2*pi,2*pi],是有4个零点.你分别猜一下就可以了.或者可以写个for循环for k=[-3,

x=0:0.02*pi:2*pisubplot(221)plot(x,sin(x))plot(x,sin(x))xlabel('x')ylabel('sin(x)')title('cos(x)')subplot(222)plot(x,cos(x))xlabel('x')title('sin(x)')ylabel('cos(x)')subplot(223)plot(x,sin(2*x))xlabel('x')title('sin(2x)')ylabel('sin(2x)')subplot(224)plot(x,tan(x))xlabel('x')title('tan(x)')ylabel('tan(x)')

clear all;clc;y=@(x)x.*sin(x);ezplot(y);grid on;--------------------------或者用数值方法(建议使用数值方法)clear all;clc;x=-2*pi:pi/20:2*pi;y=x.*sin(x);plot(x,y);grid on;

h=figure('units','normalize','position',[0.1 0.1 0.8 0.8]);h1=axes('parent',h);set(h1,'units','normalize','position',[0.1 0.1 0.4 0.8])x=0:pi/400:2*pi;y=sin(x);plot(x,y,'r')h2=axes('parent',h);set(h2,'units','normalize','position',[0.55 0.1 0.4 0.8])x=0:pi/400:2*pi;y=

x=0:pi/10:2*pi;x2=[0+0.0001:pi/1000:2*pi]y1=sin(x);y2=cos(x);y3=tan(x2);y4=cot(x2);subplot(2,2,1)plot(x,y1);axis([0,2*pi,-1.5,1.5])subplot(2,2,2)plot(x,y2);axis([0,2*pi,-1.5,1.5])subplot(2,2,3)plot(x2,y3);axis([0,2*pi,-50,50])subplot(2,2,4)plot(x2,y4);axis([0,2*pi,-50,50])

x=0:0.02*pi:2*pisubplot(221)plot(x,sin(x))plot(x,sin(x))xlabel('x')ylabel('sin(x)')tit

x=[-pi:0.01:pi];>> y=sin(x)*cos(x); plot(x,y, 'LineWidth',2)

如果x是个矩阵,要对矩阵中的每个元素进行sin(x)cos(x)的计算,一定要用点乘,即sin(x).cos(x) 如果x只是单个数,写成sin(x)*cos(x)就成,当然用点乘也可以

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.msww.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com