【正文】
ram is used to generate a sinusoidal signal and draw its plot clear, % Clear all variables close all, % Close all figure windows dt = 。 % Specify the step of time variable t = 2:dt:2。 % Specify the interval of time x = sin(2*pi*t)。 % Generate the signal plot(t,x) % Open a figure window and draw the plot of x(t) title(39。Sinusoidal signal x(t)39。) xlabel(39。Time t (sec)39。)在《通信原理》課程中,單位階躍信號u(t) 和單位沖激信號δ(t) 是二個非常有用的信號。它們的定義如下:這里分別給出相應(yīng)的簡單的產(chǎn)生單位沖激信號和單位階躍信號的擴展函數(shù)。產(chǎn)生單位沖激信號的擴展函數(shù)為: function y = delta(t) dt = 。 y = (u(t)u(tdt))/dt。 產(chǎn)生單位階躍信號的擴展函數(shù)為: % Unit step function function y = u(t) y = (t=0)。 % y = 1 for t 0, else y = 0 請將這二個MATLAB函數(shù)分別以delta 和u為文件名保存在work文件夾中,以后,就可以像教材中的方法使用單位沖激信號δ(t) 和單位階躍信號u(t)。 離散時間信號的仿真 程序Program1_2用來產(chǎn)生離散時間信號x[n]=sin()。 % Program1_2 % This program is used to generate a discretetime sinusoidal signal and draw its plot clear, % Clear all variables close all, % Close all figure windows n = 10:10。 % Specify the interval of time x = sin(*pi*n)。 % Generate the signal stem (n,x) % Open a figure window and draw the plot of x[n] title (39。Sinusoidal signal x[n]39。) xlabel (39。Time index n39。) 請仔細閱讀該程序,比較程序Program1_1和Program1_2中的不同之處,以便自己編程時能夠正確使用這種方法方針連續(xù)時間信號和離散時間信號。 程序Program1_3用來仿真下面形式的離散時間信號: x[n]={...., , , , 0, , ….} ↑n=0 % Program1_3 % This program is used to generate a discretetime sequence % and draw its plot clear, % Clear all variables close all, % Close all figure windows n = 5:5。 % Specify the interval of time, the number of points of n is 11. x = [0, 0, 0, 0, , , , 0, , 0, 0]。 % Generate the signal stem(n,x,39。.39。) % Open a figure window and draw the plot of x[n] grid on, title (39。A discretetime sequence x[n]39。) xlabel (39。Time index n39。) 由于在程序的stem(n,x,39。.39。) 語句中加有39。.39。選項,因此繪制的圖形中每根棒條線的頂端是一個實心點。 如果需要在序列的前后補較多的零的話,可以利用函數(shù)zeros(),其語法為zeros(1, N):圓括號中的1和N表示該函數(shù)將產(chǎn)生一個一行N列的矩陣,矩陣中的所有元素均為零。利用這個矩陣與序列x[n]進行組合,從而得到一個長度與n相等的向量。 例如,當 x[n]={ , , , 0, } 時,為了得到程序Program1_3中的序列, ↑n=0 可以用這個MATLAB語句x = [zeros(1,4) x zeros(1, 2)] 來實現(xiàn)。用這種方法編寫的程序如下: % Program1_4 % This program is used to generate a discretetime sinusoidal signal % and draw its plot clear, % Clear all variables close all, % Close all figure windows n = 5:5。 % Specify the interval of time x = [zeros(1,4), , , , 0, , zeros(1,2)]。 % Generate the sequence stem(n,x,39。filled39。,39。r39。) % Open a figure window and draw the plot of x[n] grid on,四、實驗步驟(1)分析程序每條指令的作用,運行該程序,將結(jié)果保存,貼在下面的空白處。然后修改程序,并執(zhí)行修改后的程序,保存圖形,看看所得圖形的效果怎樣。dt=dt=請問:上述的兩幅圖形有什么區(qū)別,哪一副圖形看起來更接近于實際信號波形?為什么會有這種區(qū)別?答:前者波形曲線光滑,后者曲折,第一幅圖更接近于實際信號波形。(2)修改program1_1,,存盤程序名為Q1_2,生成實指數(shù)信號x(t)=e2t。 要求在圖形中加上網(wǎng)格線,并使用函數(shù)axis()控制圖形的時間范圍在0~2秒之間。然后執(zhí)行該程序,保存所的圖形。 修改Program1_1后得到的程序Q1_2如下: %program1_1% This program is used to generate a sinusoidal signal and draw its plot clear, % Clear all variables close all, % Close all figure windows dt = 。 % Specify the step of time variable t = 2:dt:2。 % Specify the interval of time X=exp(2*t)。 % Generate the signal plot(t,x) % Open a figure window and draw the plot of x(t) axis{[0,2,0,2]}Grid on,title(39。Sinusoidal signal x(t) 彭龍龍 熊犇39。) xlabel(39。Time t (sec)39。)圖形結(jié)果如下: (3)將前文中所給的單位沖激信號和單位階躍信號的函數(shù)文件在MATLAB文件編輯器中編寫好,并分別以文件名delta