您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 能源与动力工程 > matlab综合大作业(附详细答案)
《MATLAB语言及应用》期末大作业报告1.数组的创建和访问(20分,每小题2分):1)利用randn函数生成均值为1,方差为4的5*5矩阵A;实验程序:A=1+sqrt(4)*randn(5)实验结果:A=0.13493.38180.62661.22791.5888-2.33123.37832.45163.1335-1.67241.25070.9247-0.17661.11862.42861.57541.65465.36640.80874.2471-1.29291.34930.7272-0.6647-0.38362)将矩阵A按列拉长得到矩阵B;实验程序:B=A(:)实验结果:B=0.1349-2.33121.25071.5754-1.29293.38183.37830.92471.65461.34930.62662.4516-0.17665.36640.72721.22793.13351.11860.8087-0.66471.5888-1.67242.42864.2471-0.38363)提取矩阵A的第2行、第3行、第2列和第4列元素组成2*2的矩阵C;实验程序:C=[A(2,2),A(2,4);A(3,2),A(3,4)]实验结果:C=3.37833.13350.92471.11864)寻找矩阵A中大于0的元素;]实验程序:G=A(find(A0))实验结果:G=0.13491.25071.57543.38183.37830.92471.65461.34930.62662.45165.36640.72721.22793.13351.11860.80871.58882.42864.24715)求矩阵A的转置矩阵D;实验程序:D=A'实验结果:D=0.1349-2.33121.25071.5754-1.29293.38183.37830.92471.65461.34930.62662.4516-0.17665.36640.72721.22793.13351.11860.8087-0.66471.5888-1.67242.42864.2471-0.38366)对矩阵A进行上下对称交换后进行左右对称交换得到矩阵E;实验程序:E=flipud(fliplr(A))实验结果:E=-0.3836-0.66470.72721.3493-1.29294.24710.80875.36641.65461.57542.42861.1186-0.17660.92471.2507-1.67243.13352.45163.3783-2.33121.58881.22790.62663.38180.13497)删除矩阵A的第2列和第4列得到矩阵F;实验程序:F=A;F(:,[2,4])=[]实验结果:F=0.13490.62661.5888-2.33122.4516-1.67241.2507-0.17662.42861.57545.36644.2471-1.29290.7272-0.38368)求矩阵A的特征值和特征向量;实验程序:[Av,Ad]=eig(A)实验结果:特征向量Av=-0.47770.1090+0.3829i0.1090-0.3829i-0.7900-0.2579-0.5651-0.5944-0.5944-0.3439-0.1272-0.28620.2779+0.0196i0.2779-0.0196i-0.0612-0.5682-0.60870.5042-0.2283i0.5042+0.2283i0.03430.67860.0080-0.1028+0.3059i-0.1028-0.3059i0.50260.3660特征值Ad=6.048100000-0.2877+3.4850i00000-0.2877-3.4850i000000.591500000-2.30249)求矩阵A的每一列的和值;实验程序:lieSUM=sum(A)实验结果:lieSUM=-0.663210.68888.99515.62406.208710)求矩阵A的每一列的平均值;实验程序:average=mean(A)实验结果:average=-0.13262.13781.79901.12481.24172.符号计算(10分,每小题5分):1)求方程组20,0uyvzwyzw关于,yz的解;实验程序:S=solve('u*y^2+v*z+w=0','y+z+w=0','y,z');y=S.y,z=S.z实验结果:y=[-1/2/u*(-2*u*w-v+(4*u*w*v+v^2-4*u*w)^(1/2))-w][-1/2/u*(-2*u*w-v-(4*u*w*v+v^2-4*u*w)^(1/2))-w]z=[1/2/u*(-2*u*w-v+(4*u*w*v+v^2-4*u*w)^(1/2))][1/2/u*(-2*u*w-v-(4*u*w*v+v^2-4*u*w)^(1/2))]2)利用dsolve求解偏微分方程,dxdyyxdtdt的解;实验程序:[x,y]=dsolve('Dx=y','Dy=-x')实验结果:x=-C1*cos(t)+C2*sin(t)y=C1*sin(t)+C2*cos(t)3.数据和函数的可视化(20分,每小题5分):1)二维图形绘制:绘制方程2222125xyaa表示的一组椭圆,其中0.5:0.5:4.5a;实验程序:t=0:0.01*pi:2*pi;fora=0.5:0.5:4.5;x=a*cos(t);y=sqrt(25-a^2)*sin(t);plot(x,y)holdonend实验结果:-5-4-3-2-1012345-5-4-3-2-10123452)利用plotyy指令在同一张图上绘制sinyx和10xy在[0,4]x上的曲线;实验程序:x=0:0.1:4;y1=sin(x);y2=10.^x;[ax,h1,h2]=plotyy(x,y1,x,y2);set(h1,'LineStyle','.','color','r');set(h2,'LineStyle','-','color','g');legend([h1,h2],{'y=sinx';'y=10^x'});实验结果:00.511.522.533.54-10100.511.522.533.540500010000y=sinxy=10x3)用曲面图表示函数22zxy;实验程序:x=-3:0.1:3;y=-3:0.1:3;[X,Y]=meshgrid(x,y);Z=X.^2+Y.^2;surf(X,Y,Z)实验结果:-4-2024-4-2024051015204)用stem函数绘制对函数cos4yt的采样序列;实验程序:t=-8:0.1:8;y=cos(pi.*t/4);stem(y)实验结果:020406080100120140160180-1-0.8-0.6-0.4-0.200.20.40.60.814.设采样频率为Fs=1000Hz,已知原始信号为)150π2sin(2)80π2sin(ttx,由于某一原因,原始信号被白噪声污染,实际获得的信号为))((ˆtsizerandnxx,要求设计出一个FIR滤波器恢复出原始信号。(20分)实验程序:t=0:0.001:0.2;x1=sin(2*pi*80*t)+2*sin(2*pi*150*t);x2=randn(size(t));%添加随机噪声;x=x1+x2;A=[1-1.1430.4128];%滤波器分母系数;B=[0.067450.13480.06745];%滤波器分子系数;y=filter(B,A,x);plot(t,x,':',t,y,'-');legend('带有噪声的信号波形','FIR滤波后信号波形');t=0:0.2:200;x=sin(2*pi*80*t)+2*sin(2*pi*150*t)+randn(size(t));n=3;f=9;[b,g]=sgolay(n,f);halfwin=((f+1)/2)-1;forn=(f+1)/2:996-(f+1)/2;SG0(n)=dot(g(:,1),x(n-halfwin:n+halfwin));endsubplot(2,1,1);plot(x(1:length(SG0)));subplot(2,1,2);plot(SG0);实验结果:01002003004005006007008009001000-4-202401002003004005006007008009001000-2-10125.人体心电图测量信号在测量的过程中经常会受到工业高频干扰,所以必须经过低通滤波处理后,才能判断心脏功能的有用信息。下面是一组实际心电图信号采样的样本x(n),其中存在高频干扰。试在实验中,通过MATLAB程序,以x(n)作为输入序列,滤出其中的干扰成分。x(n)={-4,-2,0,-4,-6,-4,-2,-4,-6,-6,-4,-4,-6,-6,-2,6,12,8,0,-16,-38,-60,-84,-90,-66,-32,-4,-2,8,12,12,10,6,6,4,0,0,0,0,0,-2,-2,0,0,-2,-2,-2,-2,0}。(20分,每小题4分))1)绘制原数据图形;2)设计巴特沃斯低通滤波器并绘制出其幅频响应曲线;3)用设计的滤波器对原数据进行滤波;绘制滤波后的数据图;4)绘制原数据功率谱图;5)绘制滤波后的数据功率谱图。解:(1)实验程序:xn=[-4-20-4-6-4-2-4-6-6-4-4-6-6-261280-16-38-60-84-90-66-32-4-2812121066400000-2-200-2-2-2-20];N=49;n=0:N-1;stem(n,xn);%绘制原数据图形title('原数据图形');实验结果:05101520253035404550-100-80-60-40-20020原数据图形(2)实验程序:N_filter=10;fs_filter=5000;%20阶滤波器,采样频率5000Hzwn_filter=1000/(fs_filter/2);%截止频率1000Hz[b,a]=butter(N_filter,wn_filter);freqz(b,a);%画出频率特性title('低通滤波器频率特性');实验结果:00.10.20.30.40.50.60.70.80.91-1000-5000NormalizedFrequency(rad/sample)Phase(degrees)00.10.20.30.40.50.60.70.80.91-400-2000200NormalizedFrequency(rad/sample)Magnitude(dB)低通滤波器频率特性(3)实验程序:yn=filter(b,a,xn);%滤波stem(n,yn);title('滤波后的数据图');实验结果:05101520253035404550-100-80-60-40-20020滤波后的数据图(4)实验程序:Nfft=1024;periodogram(xn,window,nfft,fs_filter);%绘制原数据功率谱图实验结果:00.511.522.5-50-40-30-20-10010Frequency(kHz)Power/frequency(dB/Hz)PeriodogramPowerSpectralDensityEstimate(5)实验程序:periodogram(yn,window,nfft,fs_filter);%绘制滤波后数据功率谱图实验结果:00.511.522.5-70-60-50-40-30-20-10010Frequency(kHz)Power/frequency(dB/Hz)PeriodogramPowerSpectralDensityEstimate6.已知x(n)=[2101],计算如下表达式:(10分)1)计算xn的6点DFT结果Xk;
本文标题:matlab综合大作业(附详细答案)
链接地址:https://www.777doc.com/doc-7185618 .html