资源描述:
《随机过程matlab程序》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、基本操作-5/(4.8+5.32)^2area=pi*2.5^2x1=1+1/2+1/3+1/4+1/5+1/6exp(acos(0.3))a=[123;456;789]a=[1:3,4:6,7:9]a1=[6:-1:1]a=eye(4)a1=eye(2,3)b=zeros(2,10)c=ones(2,10)c1=8*ones(3,5)d=zeros(3,2,2);r1=rand(2,3)r2=5-10*rand(2,3)r4=2*randn(2,3)+3arr1=[1.1-2.23.3-4.45.5]
2、arr1(3)arr1([14])arr1(1:2:5)arr2=[123;-2-3-4;345]arr2(1,:)arr2(:,1:2:3)arr3=[12345678]arr3(5:end)arr3(end)绘图x=[0:1:10];y=x.^2-10*x+15;plot(x,y)x=0:pi/20:2*piy1=sin(x);y2=cos(x);plot(x,y1,'b-');holdon;plot(x,y2,‘k--’);legend(‘sinx’,‘cosx’);x=0:pi/20:2*pi;
3、y=sin(x);figure(1)plot(x,y,'r-')gridon以二元函数图z=xexp(-x^2-y^2)为例讲解基本操作,首先需要利用meshgrid函数生成X-Y平面的网格数据,如下所示:xa=-2:0.2:2;ya=xa;[x,y]=meshgrid(xa,ya);z=x.*exp(-x.^2-y.^2);mesh(x,y,z);建立M文件functionfenshu(grade)ifgrade>95.0disp('ThegradeisA.');elseifgrade>86.0dis
4、p('ThegradeisB.');elseifgrade>76.0disp('ThegradeisC.');elseifgrade>66.0disp('ThegradeisD.');elsedisp('ThegradeisF.');endendendendendfunctiony=func(x)ifabs(x)<1y=sqrt(1-x^2);elsey=x^2-1;endfunctionsumm(n)i=1;sum=0;while(i<=n)sum=sum+i;i=i+1;endstr=['¼ÆËã½
5、á¹ûΪ£º',num2str(sum)];disp(str)end求极限symsxlimit((1+x)^(1/x),x,0,'right')求导数symsx;f=(sin(x)/x);diff(f)diff(log(sin(x)))求积分symsx;int(x^2*log(x))symsx;int(abs(x-1),0,2)常微分方程求解dsolve('Dy+2*x*y=x*exp(-x^2)','x')计算偏导数x/(x^2+y^2+z^2)^(1/2)diff((x^2+y^2+z^2)^(1
6、/2),x,2)重积分int(int(x*y,y,2*x,x^2+1),x,0,1)级数symsn;symsum(1/2^n,1,inf)Taylor展开式求y=exp(x)在x=0处的5阶Taylor展开式taylor(exp(x),0,6)矩阵求逆A=[0-6-1;62-16;-520-10]det(A)inv(A)特征值、特征向量和特征多项式A=[0-6-1;62-16;-520-10];lambda=eig(A)[v,d]=eig(A)poly(A)多项式的根与计算p=[10-2-5];r=ro
7、ots(p)p2=poly(r)y1=polyval(p,4)例子:x=[-3:3]'y=[3.03,3.90,4.35,4.50,4.40,4.02,3.26]';A=[2*x,2*y,ones(size(x))];B=x.^2+y.^2;c=inv(A'*A)*A'*B;r=sqrt(c(3)+c(1)^2+c(2)^2)例子ezplot('-2/3*exp(-t)+5/3*exp(2*t)','-2/3*exp(-t)+2/3*exp(2*t)',[0,1])gridon;axis([0,12,0
8、,5])密度函数和概率分布设x~b(20,0.1),binopdf(2,20,0.1)分布函数设x~N(1100,502),y~N(1150,802),则有normcdf(1000,1100,50)=0.0228,1-0.0228=0.9772normcdf(1000,1150,80)=0.0304,1-0.0304=0.9696统计量数字特征x=[29.827.628.3]mean(x)max(x)min(x)std(x)symspk;E