当前位置:网站首页>MATLAB综合练习:信号与系统中的应用
MATLAB综合练习:信号与系统中的应用
2022-07-06 09:25:00 【Bitter tea seeds】
MATLAB 2018b
前言
“老爸,你昨天给我发的时域信号的频谱分析作业老师超级满意,她又留新的作业了,你帮找你那个员工在帮我做一下吧,我都不咋会。”
苦茶子老板,没好气的哼了一声:“你就不能自己学一点吗?你以后出来能干什么?就天天指着我给你每个月50万的零花钱,你这样以后怎么活下去啊!”
“别唠叨了,臭老头,拜拜,老子耍去了!”
“哎!“苦茶子老板叹了口气,接着让女秘书把小刘叫到办公室来。
”小刘啊!昨天你做的作业,我呢,真的是非常的满意,为了继续锻炼你的能力,这里还有几道题,你也做了吧!啊,不咋多。“苦茶子老板板着脸说着。
小刘想着拒绝,当看见老板板着生气的脸,也不敢张开那个嘴了,只是糯糯的说了声:”好的,老板。“
”文档发你了,赶紧写了去吧!“老板把小刘赶出了办公室。
小刘回到了办公桌前,看着那么多的题,默默的打开了CSDN搜索到:”如何和老板提涨工资啊?“
一、产生数值信号
利用MATLAB产生信号 x(t)=cos(10Πt),y(t)=sin(10Πt2)
,分别画出信号的波形,并画在一张图上比较这两个信号的波形。
代码如下,所示:
>> t=linspace(0,8*pi,100);%创建0到4Π的线性分隔数值向量t,元素为100个
>> x=cos(10*pi*t);%x(t)的波形;
>> plot(t,x,'r'),title('x(t)波形曲线'),xlabel('t数值向量')
>> y=sin(10*pi*t.^2);%y(t)的波形;
>> plot(t,y,'c'),title('y(t)波形曲线'),xlabel('t数值向量')
>> plot(t,x,'r',t,y,'c')
>> title('x(t)和y(t)进行比较')
>> xlabel('t数值向量')
1.单独x的波形图:
2.单独y的波形图:
3.x(t)信号波形和y(t)信号波形进行比较:
二、信号的基本运算
利用MATLAB实现信号f1 (t)=sin(πt),f2(t)=sin(10πt)的相加和相乘,试分别绘制这两个信号及它们的和信号和积信号的波形。
代码如下,所示:
>> t=linspace(0,8*pi,100);%创建0到4Π的线性分隔数值向量t,元素为100个
>> f1=sin(pi*t);%f1信号函数表达式
>> f2=sin(10*pi*t);%f2信号函数表达式
>> subplot(1,2,1),plot(t,f1,'m'),title('x(t)的波形曲线')
>> subplot(1,2,2),plot(t,f2,'w'),title('y(t)的波形曲线')
>> f3=f1+f2;
>> format short,f3;
>> plot(t,f3),title('f3为信号和波形曲线')
>> f4=f1.*f2;
>> plot(t,f4,'m'),title('f4为信号乘积波形曲线')
1.f1、f2的波形曲线:
2.f3俩信号乘积和的波形曲线
3.f4俩信号乘积的波形曲线
三、卷积的运算
用MATLAB画出门函数3[u(t+1)-u(t-2)]与指数函数2e^(-2t)卷积图形。
代码如下,所示:
>> dt=0.01; t=0:dt:5;
>> f1=3*(u.*(t+1)-u.*(t-2)); subplot(1,3,1), plot(t,f1,'g') ,title('门函数波形曲线')
>> f2=2*exp(-2.*t); subplot(1,3,2), plot(t,f2,'r'),title('指数函数波形曲线')
>> y =conv(f1,f2)*dt;%调用卷积conv()函数
>> subplot(1,3,3), plot(dt*([1:length(y)]-1),y,'m'), title('卷积曲线'),grid % 不知t的长度,绘图时t数组设定方法
门函数,指数函数、还有俩信号的卷积波形如下:
四、傅里叶级数展开
利用MATLAB将基频为50Hz的方波展开为傅里叶级数。
代码如下,所示:
>> N = 500; %取项,并且项数越高,波形越不失真。
>> T = 0.02;%方波周期为0.02;
>> fs = 1/T;%方波基频为50Hz;
>> N_point = 150; %设置每个周期的采样点个数
>> dt = T/N_point;%步长
>> t=1:dt:100*T-dt;%取值范围,”不宜过大“
>> ft = zeros(1,length(t));
>> %ft为全0矩阵
>> for n=1:N
an = (2*sin(pi*n) - sin(2*pi*n))/(pi*n);
bn = (1-2*cos(n*pi)+cos(2*pi*n))/(pi*n);
ft = ft + an*cos(n*2*pi*fs*t)+bn*(sin(n*2*pi*fs*t));%傅里叶展开级数
end
>> plot(t,ft,'m')
>> title('基频为50Hz的方波展开为傅里叶级数')
基频为50Hz的方波:
各次谐波合成方波的情况:
五、频谱分析
用MATLAB画出H(s)=s2/((s+1)2+1)的零、极点分布图,并画出该系统的冲激响应h(n)的波形和频率响应H(jω)的曲线,判断系统是低通、高通、带通、带阻中哪一种?
代码如下,所示:
>> a = [1 2 2];% 分母向量
>> b = [1]; % 分子向量
>> zs=roots(b) %求系统的零点
zs =
空的 0×1 double 列向量
>> ps=roots(a) %求系统的极点
ps =
-1.0000 + 1.0000i
-1.0000 - 1.0000i
>> plot(real(zs), imag(zs), 'go', real(ps), imag(ps), 'mx', 'markersize', 12);
>> grid; legend('零点','极点');
>>figure(1); pzmap(sys); % 画出零点极点图
>> figure(2);freqs(b, a, w);% 画出幅频特性曲线和相频特性曲线
>> dn=0.1; n=0:dn:6;%n取值范围
>> [r,p,k]=residue( b, a);%用极点留数法求冲击函数
>> H=zeros(1,length(n));
>> for i=1:length(a)-1
H=H+r(i)*exp(p(i)*n);% 冲击函数h(n)的通用式
end
>> plot(n,H); grid; title('冲激响应H(t)')
>> freqs(b,a,w) %滤波器的频率响应
1.零、极点图:
2.幅频特性曲线和相频特性曲线:
3.冲激函数H(t):
4.频率响应H(jω)的曲线:
总结
小刘终于将这些题给做完了,他伸了伸懒腰,看了看时间,已经晚上21:35了,看了看老板办公室已经熄灯了,估计老板已经回家睡觉了,明天再发给他吧。再看了看周围没走几个人的办公室,摇了摇头,给自己冲了杯咖啡,继续看着今天下午的提问:”如何让老板给自己加薪呢?“
边栏推荐
- Currently, mysql5.6 is used. Which version would you like to upgrade to?
- Winter vacation daily question - maximum number of balloons
- Mysql的事务
- Brief description of compiler optimization level
- 学习记录:串口通信和遇到的错误解决方法
- Portapack application development tutorial (XVII) nRF24L01 launch B
- [pytorch] simple use of interpolate
- 自动化测试中敏捷测试怎么做?
- Es6--- two methods of capturing promise status as failed
- [200 opencv routines] 98 Statistical sorting filter
猜你喜欢
ucore lab7
ucore lab 6
Scoring system based on 485 bus
安全测试入门介绍
Crawling cat's eye movie review, data visualization analysis source code operation instructions
Unpleasant error typeerror: cannot perform 'ROR_‘ with a dtyped [float64] array and scalar of type [bool]
ucore lab7
Stm32 dossiers d'apprentissage: saisie des applications
UCORE lab8 file system experiment report
The wechat red envelope cover designed by the object is free! 16888
随机推荐
Research Report of pharmaceutical solvent industry - market status analysis and development prospect prediction
MySQL数据库(三)高级数据查询语句
How to rename multiple folders and add unified new content to folder names
软件测试需求分析之什么是“试纸测试”
LeetCode#36. Effective Sudoku
ucore lab 2
Research Report on medical anesthesia machine industry - market status analysis and development prospect prediction
Mysql database (I)
Lab 8 file system
Research Report on market supply and demand and strategy of Chinese hospital cleaning chemicals industry
Do you know the advantages and disadvantages of several open source automated testing frameworks?
JDBC介绍
Stm32 dossiers d'apprentissage: saisie des applications
Should wildcard import be avoided- Should wildcard import be avoided?
Collection集合与Map集合
Automated testing problems you must understand, boutique summary
Brief introduction to libevent
What are the software testing methods? Show you something different
如何成为一个好的软件测试员?绝大多数人都不知道的秘密
ucore lab 6