1.代码
%生成一个10Hz方波,其采样率为1kHz,持续时间为500毫秒。指定占空比为50% t=0:1/1e3:0.5; y =square(2*pi*10*t,50); dutycycle(y,t) %生成10个三角波,频率为50Hz。采样率为1kHz。 T = 10*(1/50); fs = 1000; t = 0:1/fs:T-1/fs; x1=sawtooth(2*pi*50*t,0); x2=sawtooth(2*pi*50*t,1/2); x3=sawtooth(2*pi*50*t,1); subplot(3,1,1) plot(t,x1) subplot(3,1,2) plot(t,x2) subplot(3,1,3) plot(t,x3) %生成非周期矩形脉冲 %生成200毫秒的矩形脉冲,其采样率为10kHz,宽度为20毫秒。 fs = 10e3; t = -0.1:1/fs:0.1; w = 20e-3; x = rectpuls(t,w); %向左移45毫秒。 tpast = -45e-3; xpast = rectpuls(t-tpast,w); %向右移60毫秒,且宽度减半。 tfutr = 60e-3; xfutr = rectpuls(t-tfutr,w/2); plot(t,x,t,xpast,t,xfutr) ylim([-0.2 1.2]) %生成非周期三角波 %Generate 200 ms of a symmetric triangular pulse with a sample rate of 10 kHz and a width of 40 ms. fs = 10e3; t = -0.1:1/fs:0.1; w = 40e-3; x = tripuls(t,w); %One displaced 45 ms into the past and skewed 45% to the left. tpast = -45e-3; spast = -0.45; xpast = tripuls(t-tpast,w,spast); %One displaced 60 ms into the future, half as wide, and skewed completely to the right. tfutr = 60e-3; sfutr = 1; xfutr = tripuls(t-tfutr,w/2,sfutr); plot(t,x,t,xpast,t,xfutr) ylim([-0.2 1.2]) %sinc和diric t=-2*pi:1/50:2*pi; subplot(2,1,1); plot(t,sinc(t)); title('Sinc'); subplot(2,1,2); plot(t,diric(t,7)); title('Diric'); %高斯正弦脉冲信号 %Plot a 50 kHz Gaussian RF pulse with 60 bandwidth, %sampled at a rate of 10 MHz. Truncate the pulse where the envelope falls 40 dB below the peak. %Also plot the quadrature pulse and the RF signal envelope. tc = gauspuls('cutoff',50e3,0.6,[],-40); t = -tc : 1e-7 : tc; [yi,yq,ye] = gauspuls(t,50e3,0.6); plot(t,yi,t,yq,t,ye) legend('Inphase','Quadrature','Envelope')
2.运行结果