




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、數(shù)字信號(hào)處理MATLAB上機(jī)作業(yè)M 2.21. 題目The square wave and the sawtooth wave are two periodic sequences as sketched in figure P2.4.Using the function stem. The input data specified by the user are: desired length L of the sequence, peak value A, and the period N. For the square wave sequence an additional user-s
2、pecified parameter is the duty cycle, which is the percent of the period for which the signal is positive. Using this program generate the first 100 samples of each of the above sequences with a sampling rate of 20 kHz ,a peak value of 7, a period of 13 ,and a duty cycle of 60% for the square wave.
3、2. 程序% 用戶定義各項(xiàng)參數(shù)參數(shù)A = input('The peak value =');L = input('Length of sequence =');N = input('The period of sequence =');FT = input('The desired sampling frequency =');DC = input('The square wave duty cycle = ');% 產(chǎn)生所需要的信號(hào)t = 0:L-1;T = 1/FT;x = A*sawtooth(2*pi*t
4、/N);y = A*square(2*pi*(t/N),DC);% Plotsubplot(2,1,1)stem(t,x);ylabel('幅度');xlabel('n');subplot(2,1,2)stem(t,y);ylabel('幅度');xlabel('n');3. 結(jié)果4. 結(jié)果分析M 2.41. 題目(a) Write a matlab program to generate a sinusoidal sequence xn= Acos(0 n+) and plot the sequence using the st
5、em function. The input data specified by the user are the desired length L, amplitude A, the angular frequency 0 , and the phase where 0<0 <pi and 0<=<=2pi. Using this program generate the sinusoidal sequences shown in figure 2.15.(b) Generate sinusoidal sequences with the angular freque
6、ncies given in Problem 2.22. Determine the period of each sequence from the plot and verify the result theoretically.2. 程序%用戶定義的參數(shù)L = input('Desired length = ');A = input('Amplitude = ');omega = input('Angular frequency = ');phi = input('Phase = ');%信號(hào)產(chǎn)生n = 0:L-1;x =
7、A*cos(omega*n + phi);stem(n,x);xlabel('n');ylabel('幅度');title('omega_o = ',num2str(omega);3. 結(jié)果(a)0=00=0.10=0.80=1.2(b)0=0.140=0.240=0.340=0.680=0.754. 結(jié)果分析M 2.51. 題目Generate the sequences of problem 2.21(b) to 2.21(e) using matlab.2. 程序(b)n = 0 : 99;x=sin(0.6*pi*n+0.6*pi);st
8、em(n,x);xlabel('n');ylabel('幅度');(c)n = 0 : 99;x=2*cos(1.1*pi*n-0.5*pi)+2*sin(0.7*pi*n);stem(n,x);xlabel('n');ylabel('幅度');(d)n = 0 : 99;x=3*sin(1.3*pi*n-4*cos(0.3*pi*n+0.45*pi);stem(n,x);xlabel('n');ylabel('幅度');(e)n = 0 : 99;x=5*sin(1.2*pi*n+0.65*pi)
9、+4*sin(0.8*pi*n)-cos(0.8*pi*n);stem(n,x);xlabel('n');ylabel('幅度');(f)n = 0 : 99;x=mod(n,6);stem(n,x);xlabel('n');ylabel('幅度');3. 結(jié)果(b) (c) (d) (e) (f) 4. 結(jié)果分析M 2.61. 題目Write a matlab program to plot a continuous-time sinusoidal signal and its sampled version and verif
10、y figure 2.19. You need to use the hold function to keep both plots.2. 程序%用戶定義的參數(shù)fo = input('Frequency of sinusoid in Hz = ');FT = input('Samplig frequency in Hz = ');%產(chǎn)生信號(hào)t = 0:0.001:1;g1 = cos(2*pi*fo*t);plot(t,g1,'-')xlabel('時(shí)間t');ylabel('幅度')holdn = 0:1:FT
11、;gs = cos(2*pi*fo*n/FT);plot(n/FT,gs,'o');hold off3. 結(jié)果4. 結(jié)果分析M 3.11. 題目Using program 3_1 determine and plot the real and imaginary parts and the magnitude and phase spectra of the following DTFT for various values of r and :Gej=11-2rcose-j+r2e-2j , 0<r<1.2. 程序%program 3_1%discrete-tim
12、e fourier transform computatition%k=input('Number of frequency points = ');num=input('Numerator coefficients= ');den=input('Denominator coefficients= ');%computer the frequency responsew=0:pi/k:pi;h=freqz(num,den,w);%plot the frequency responsesubplot(221)plot(w/pi,real(h);gr
13、idtitle('real part')xlabel('omega/pi');ylabel('Amplitude')subplot(222)plot(w/pi,imag(h);gridtitle('imaginary part')xlabel('omega/pi');ylabel('Amplitude')subplot(223)plot(w/pi,abs(h);gridtitle('magnitude spectrum')xlabel('omega/pi');ylab
14、el('magnitude')subplot(224)plot(w/pi,angle(h);gridtitle('phase spectrum')xlabel('omega/pi');ylabel('phase,radians')3. 結(jié)果(a) r=0.8 =/6(b) r=0.6 = /3 4. 結(jié)果分析M 3.41. 題目Using matlab verify the following general properties of the DTFT as listed in Table 3.2:(a) Linearity,
15、(b) time-shifting, (c) frequency-shifting, (d) differentiation-in-frequency, (e) convolution, (f) modulation, and (g) Parsevals relation. Since all data in matlab have to be finite-length vectors, the sequences to be used to verify the properties are thus restricted to be of finite length.2. 程序%先定義兩
16、個(gè)信號(hào)N = input('The length of the sequence = ');k = 0:N-1;%g為正弦信號(hào)g = 2*sin(2*pi*k/(N/2);%h為余弦信號(hào)h = 3*cos(2*pi*k/(N/2);G,w = freqz(g,1);H,w = freqz(h,1);%*% 線性性質(zhì)alpha = 0.5;beta = 0.25;y = alpha*g+beta*h;Y,w = freqz(y,1);figure(1);subplot(211),plot(w/pi,abs(Y);xlabel('omega/pi');ylabel(
17、'|Y(ejomega)|');title('線性疊加后的頻率特性');grid;% 畫出 Y 的頻率特性subplot(212),plot(w/pi,alpha*abs(G)+beta*abs(H);xlabel('omega/pi');ylabel('alpha|G(ejomega)|+beta|H(ejomega)|');title('線性疊加前的頻率特性');grid;% 畫出alpha*G+beta*H 的頻率特性%*% 時(shí)移性質(zhì)n0 = 10;%時(shí)移10個(gè)的單位y2 = zeros(1,n0) g;Y2
18、,w = freqz(y2,1);G0 = exp(-j*w*n0).*G;figure(2);subplot(211),plot(w/pi,abs(G0);xlabel('omega/pi');ylabel('|G0(ejomega)|');title('G0的頻率特性');grid;% 畫出 G0的頻率特性subplot(212),plot(w/pi,abs(Y2);xlabel('omega/pi');ylabel('|Y2(ejomega)|');title('Y2的頻率特性');grid;
19、% 畫出Y2 的頻率特性%*% 頻移特性w0 = pi/2; % 頻移pi/2r=256; %the value of w0 in terms of number of samplesk = 0:N-1;y3 = g.*exp(j*w0*k);Y3,w = freqz(y3,1);% 對(duì)采樣的512個(gè)點(diǎn)分別進(jìn)行減少pi/2,從而生成G(exp(w-w0)k = 0:511;w = -w0+pi*k/512; G1 = freqz(g,1,w);figure(3);subplot(211),plot(w/pi,abs(Y3);xlabel('omega/pi');ylabel(&
20、#39;|Y3(ejomega)|');title('Y3的頻率特性');grid;% 畫出 Y3的頻率特性subplot(212),plot(w/pi,abs(G1);xlabel('omega/pi');ylabel('|G1(ejomega)|');title('G1的頻率特性');grid;% 畫出G1 的頻率特性%*% 頻域微分k = 0:N-1;y4 = k.*g;Y4,w = freqz(y4,1);%在頻域進(jìn)行微分y0 = (-1).k).*g;G2 = G(2:512)' sum(y0)'
21、delG = (G2-G)*512/pi;figure(4);subplot(211),plot(w/pi,abs(Y4);xlabel('omega/pi');ylabel('|Y4(ejomega)|');title('Y4的頻率特性');grid;% 畫出 Y4的頻率特性subplot(212),plot(w/pi,abs(delG);xlabel('omega/pi');ylabel('|delG(ejomega)|');title('delG的頻率特性');grid;% 畫出delG的頻率
22、特性%*% 相乘性質(zhì)y5 = conv(g,h);%時(shí)域卷積Y5,w = freqz(y5,1);figure(5);subplot(211),plot(w/pi,abs(Y5);xlabel('omega/pi');ylabel('|Y5(ejomega)|');title('Y5的頻率特性');grid;% 畫出 Y5的頻率特性subplot(212),plot(w/pi,abs(G.*H);%頻域乘積xlabel('omega/pi');ylabel('|G.*H(ejomega)|');title('
23、;G.*H的頻率特性');grid;% 畫出G.*H的頻率特性%*% 帕斯瓦爾定理y6 = g.*h;%對(duì)于freqz函數(shù),在0到2pi直接取樣Y6,w = freqz(y6,1,512,'whole');G0,w = freqz(g,1,512,'whole');H0,w = freqz(h,1,512,'whole');% Evaluate the sample value at w = pi/2% and verify with Y6 at pi/2H1 = fliplr(H0(1:129)') fliplr(H0(130:
24、512)')'val = 1/(512)*sum(G0.*H1);% Compare val with Y6(129) i.e sample at pi/2% Can extend this to other points similarly% Parsevals theoremval1 = sum(g.*conj(h);val2 = sum(G0.*conj(H0)/512;% Comapre val1 with val23. 結(jié)果(a)(b)(c)(d)(e)4. 結(jié)果分析M 3.81. 題目Using matlab compute the N-point DFTs of
25、the length-N sequences of Problem 3.12 for N=3, 5, 7, and 10. Compare your results with that obtained by evaluating the DTFTs computed in Problem 3.12 at = 2pik/N, k=0, 1,N-1.2. 程序%用戶定義N的長(zhǎng)度N = input('The value of N = ');k = -N:N;y1 = ones(1,2*N+1);w = 0:2*pi/255:2*pi;Y1 = freqz(y1, 1, w);%對(duì)y
26、1做傅里葉變換Y1dft = fft(y1);k = 0:1:2*N;plot(w/pi,abs(Y1),k*2/(2*N+1),abs(Y1dft),'o');grid;xlabel('歸一化頻率');ylabel('幅度');(a) clf;N = input('The value of N = ');k = -N:N;y1 = ones(1,2*N+1);w = 0:2*pi/255:2*pi;Y1 = freqz(y1, 1, w);Y1dft = fft(y1);k = 0:1:2*N;plot(w/pi,abs(Y1)
27、,k*2/(2*N+1),abs(Y1dft),'o');xlabel('Normalized frequency');ylabel('Amplitude');(b) %用戶定義N的長(zhǎng)度N = input('The value of N = ');k = -N:N;y1 = ones(1,2*N+1);y2 = y1 - abs(k)/N;w = 0:2*pi/255:2*pi;Y2 = freqz(y2, 1, w);%對(duì)y1做傅里葉變換Y2dft = fft(y2);k = 0:1:2*N;plot(w/pi,abs(Y2),
28、k*2/(2*N+1),abs(Y2dft),'o');grid;xlabel('歸一化頻率');ylabel('幅度');(c) %用戶定義N的長(zhǎng)度N = input('The value of N = ');k = -N:N;y3 =cos(pi*k/(2*N);w = 0:2*pi/255:2*pi;Y3 = freqz(y3, 1, w);%對(duì)y1做傅里葉變換Y3dft = fft(y3);k = 0:1:2*N;plot(w/pi,abs(Y3),k*2/(2*N+1),abs(Y3dft),'o');g
29、rid;xlabel('歸一化頻率');ylabel('幅度');3. 結(jié)果(a) N=3 N=5 N=7 N=10 (b) N=3 N=5 N=7 N=10 (c) N=3 N=5 N=7 N=10 4. 結(jié)果分析M 3.191. 題目Using Program 3_10 determine the z-transform as a ratio of two polynomials in z-1 from each of the partial-fraction expansions listed below:(a) X1z=-2+104+z-1-82+z-1
30、 , z>0.5,(b) X2z=3.5-21-0.5z-1-3+z-11-0.25z-2 , z>0.5,(c) X3z=53+2z-12-43+2z-1+31+0.81z-2 , z>0.9,(d) X4z=4+105+2z-1+z-16+5z-1+z-2 , z>0.5.2. 程序% Program 3_10% Partical-Fraction Expansion to rational z-Transform%r = input('Type in the residues = ');p = input('Type in the poles = ');k = input('Type in the constants = ');num, den = residuez(r,p,k);disp('Numberator polynominal coefficients');disp(num)disp('Denominator polynomial coefficients&
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 培訓(xùn)店?duì)I銷管理制度
- 培訓(xùn)班精益管理制度
- 外賣人員工管理制度
- 外購件進(jìn)廠管理制度
- 多能工培訓(xùn)管理制度
- 大劇院贈(zèng)票管理制度
- 大店帶小店管理制度
- 大米篩下物管理制度
- 天然氣安全管理制度
- 奶茶店用工管理制度
- 2025年報(bào)關(guān)操作技巧與核心要點(diǎn)
- 2025年統(tǒng)編版小學(xué)語文五年級(jí)下冊(cè)期末綜合測(cè)試題及參考答案
- 浙江臨安招聘事業(yè)編制筆試真題2024
- 2024-2025學(xué)年人教版八年級(jí)數(shù)學(xué)下冊(cè)期末綜合復(fù)習(xí)解答壓軸題培優(yōu)提升專題訓(xùn)練+
- 2025年高考數(shù)學(xué)全國一卷試題真題及答案詳解(精校打?。?/a>
- DB62T 4130-2020 公路混凝土構(gòu)件蒸汽養(yǎng)護(hù)技術(shù)規(guī)程
- 洗浴中心保安合同范本
- 行政人事部所需各類表格模板
- 2024北京西城區(qū)六年級(jí)畢業(yè)考英語試題及答案
- SH3508標(biāo)準(zhǔn)培訓(xùn)課件
- 2025-2026學(xué)年建德市數(shù)學(xué)三年級(jí)第一學(xué)期期末試題含解析
評(píng)論
0/150
提交評(píng)論