当前位置:网站首页>Matlab comprehensive exercise: application in signal and system

Matlab comprehensive exercise: application in signal and system

2022-07-06 15:41:00 Bitter tea seeds


MATLAB 2018b

Preface

“ dad , The teacher is very satisfied with the spectrum analysis of time domain signals you sent me yesterday , She left new homework again , Please help me find your employee to help me , I'm not very good at .”
Boss kuchazi , He snorted unhappily :“ Can't you learn a little by yourself ? What can you do when you come out in the future ? Just point to me every day and give you every month 50 Ten thousand pocket money , How can you survive like this !”
“ Stop nagging , Stinky old man , Bye-bye , I fooled !”
“ Ah !“ The boss of kuchazi sighed , Then let the female secretary call Xiao Liu to the office .
” Xiao Liu ! The homework you did yesterday , I? , I'm really satisfied , In order to continue to exercise your ability , Here are a few more questions , You did it too ! ah , Not much .“ Kuchazi's boss said with a straight face .
Xiao Liu thought of refusing , When I see the boss's angry face , I dare not open that mouth , Just waxy said :” well , Boss .“
” The document was sent to you , Write it quickly !“ The boss kicked Xiao Liu out of the office .
Xiao Liu returned to his desk , Looking at so many questions , Silently opened CSDN Search for :” How to raise salary with the boss ?“


One 、 Generate numerical signals

utilize MATLAB Generate signals x(t)=cos(10Πt),y(t)=sin(10Πt2)
, Draw the waveform of the signal respectively , And draw a picture to compare the waveforms of the two signals .

The code is as follows , Shown :

>> t=linspace(0,8*pi,100);% establish 0 To 4Π Linearly separated numeric vector of t, Element is 100 individual 
>> x=cos(10*pi*t);%x(t) Waveform of ;
>> plot(t,x,'r'),title('x(t) wavy curve '),xlabel('t Numeric vectors ')
>> y=sin(10*pi*t.^2);%y(t) Waveform of ;
>> plot(t,y,'c'),title('y(t) wavy curve '),xlabel('t Numeric vectors ')
>> plot(t,x,'r',t,y,'c')
>> title('x(t) and y(t) Compare ')
>> xlabel('t Numeric vectors ')

1. A separate x Oscillogram of :
 A separate x Oscillogram of
2. A separate y Oscillogram of :
 A separate y Oscillogram of :
3.x(t) Signal waveform and y(t) Compare the signal waveform :
x(t) Signal waveform and y(t) Compare the signal waveform :

Two 、 The basic operation of the signal

utilize MATLAB Realization signal f1 (t)=sin⁡(πt),f2(t)=sin⁡(10πt) Add and multiply , Try to draw the waveforms of these two signals and their sum and product signals respectively .

The code is as follows , Shown :

>> t=linspace(0,8*pi,100);% establish 0 To 4Π Linearly separated numeric vector of t, Element is 100 individual 
>> f1=sin(pi*t);%f1 Signal function expression 
>> f2=sin(10*pi*t);%f2 Signal function expression 
>> subplot(1,2,1),plot(t,f1,'m'),title('x(t) The waveform curve of ')
>> subplot(1,2,2),plot(t,f2,'w'),title('y(t) The waveform curve of ')
>> f3=f1+f2;
>> format short,f3;
>> plot(t,f3),title('f3 Is the signal and waveform curve ')
>> f4=f1.*f2;
>> plot(t,f4,'m'),title('f4 Is the waveform curve of signal product ')

1.f1、f2 The waveform curve of :
f1、f2 The waveform curve of
2.f3 Waveform curve of the product sum of two signals
f3 Waveform curve of the product sum of two signals
3.f4 Waveform curve of the product of two signals
f4 Waveform curve of the product of two signals

3、 ... and 、 Convolution operation

use MATLAB Draw out the function 3[u(t+1)-u(t-2)] And exponential function 2e^(-2t) Convolution graph .

The code is as follows , Shown :

>> dt=0.01; t=0:dt:5;
>> f1=3*(u.*(t+1)-u.*(t-2)); subplot(1,3,1), plot(t,f1,'g') ,title(' Gate function waveform curve ')
>> f2=2*exp(-2.*t); subplot(1,3,2), plot(t,f2,'r'),title(' Exponential function waveform curve ')
>> y =conv(f1,f2)*dt;% Call convolution conv() function 
>> subplot(1,3,3), plot(dt*([1:length(y)]-1),y,'m'), title(' Convolution curve '),grid  %  Ignorance t The length of , When drawing t Array setting method 

Gate function , Exponential function 、 The convolution waveforms of the two signals are as follows :
 Gate function , Exponential function 、 The convolution waveforms of the two signals are as follows :

Four 、 Fourier series expansion

utilize MATLAB Set the fundamental frequency to 50Hz The square wave expansion of is Fourier series .

The code is as follows , Shown :

>> N = 500; % Take item , And the higher the number of items , The less distorted the waveform .
>> T = 0.02;% The period of the square wave is 0.02;
>> fs = 1/T;% The fundamental frequency of square wave is 50Hz;
>> N_point = 150; % Set the number of sampling points per cycle 
>> dt = T/N_point;% step 
>> t=1:dt:100*T-dt;% Value range ,” Shoulds not be too large “
>> ft = zeros(1,length(t));
>> %ft For all 0 matrix 
>> 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));% Fourier expansion series 
end
>> plot(t,ft,'m')
>> title(' The fundamental frequency is 50Hz The square wave expansion of is Fourier series ')

The fundamental frequency is 50Hz The square wave :
 The fundamental frequency is 50Hz The square wave ,t=0:dt:10*T-dt;
The situation of square wave synthesized by each harmonic :
 The situation of square wave synthesized by each harmonic
 The situation of square wave synthesized by each harmonic

5、 ... and 、 Spectrum analysis

use MATLAB Draw H(s)=s2/((s+1)2+1) Zero of 、 Pole distribution diagram , And draw the impulse response of the system h(n) Waveform and frequency response H(jω) The curve of , Judge whether the system is low-pass 、 qualcomm 、 Bandpass 、 Which kind of band stop ?

The code is as follows , Shown :

>> a = [1 2 2];%  Denominator vector 
>> b = [1]; %  Molecular vector 
>> zs=roots(b)  % Find the zero point of the system 
zs =

   Empty  0×1 double  Column vector 
>> ps=roots(a)  % Find the pole of the system 
ps =

  -1.0000 + 1.0000i
  -1.0000 - 1.0000i
>> plot(real(zs), imag(zs), 'go', real(ps), imag(ps), 'mx', 'markersize', 12);
>> grid; legend(' zero ',' pole ');
>>figure(1); pzmap(sys); %  Draw the zero pole diagram 
>> figure(2);freqs(b, a, w);%  Draw the amplitude frequency characteristic curve and phase frequency characteristic curve 
>> dn=0.1; n=0:dn:6;%n Value range 
>> [r,p,k]=residue( b, a);% Use the pole residue method to find the impact function 
>> H=zeros(1,length(n));
>> for i=1:length(a)-1
H=H+r(i)*exp(p(i)*n);%  Shock function h(n) General formula of 
end
>> plot(n,H); grid; title(' Impulse response H(t)')![ Insert picture description here ](https://img-blog.csdnimg.cn/d25cf9c7d0764f569678bfd9e8288153.png)

>> freqs(b,a,w) % The frequency response of the filter 

1. zero 、 Pole diagram :
 zero 、 Pole diagram :

2. Amplitude frequency characteristic curve and phase frequency characteristic curve :
 Amplitude frequency characteristic curve and phase frequency characteristic curve
3. Impulse function H(t):
 Impulse function H(t):
4. Frequency response H(jω) The curve of :
 Frequency response H(jω) The curve of


summary

Xiao Liu finally finished these questions , He stretched himself , Look at the time , It's already night 21:35 了 , After looking at the boss' office, the light has gone out , It is estimated that the boss has gone home to sleep , Send it to him tomorrow . Take another look at the office where there are few people around , Shook his head , Make yourself a cup of coffee , Continue to look at the questions this afternoon :” How to get the boss to give himself a raise ?“

原网站

版权声明
本文为[Bitter tea seeds]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060919236461.html