1942 1

[Weka及其他] MATLAB课程:代码示例之Signal Processing and Communications(一) [推广有奖]

企业贵宾

已卖:160份资源

巨擘

0%

还不是VIP/贵宾

-

威望
4
论坛币
624047 个
通用积分
180.5582
学术水平
918 点
热心指数
987 点
信用等级
841 点
经验
399203 点
帖子
9786
精华
48
在线时间
17322 小时
注册时间
2014-8-19
最后登录
2022-11-2

楼主
widen我的世界 学生认证  发表于 2016-3-11 14:15:15 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

MATLAB课程:代码示例之Signal Processing and Communications(一)

Signal Generation and Visualization


This example shows how to generate widely used periodic and aperiodic waveforms, sequences (impulse, step, ramp), multichannel signals, pulse trains, sinc and Dirichlet functions available in the Signal Processing Toolbox™.


Periodic Waveforms

In addition to the sin and cos functions in MATLAB®, the toolbox offers other functions that produce periodic signals such as sawtooth and square.

The sawtooth function generates a sawtooth wave with peaks at +/- 1 and a period of 2*pi. An optional width parameter specifies a fractional multiple of 2*pi at which the signal's maximum occurs.

The square function generates a square wave with a period of 2*pi. An optional parameter specifies duty cycle, the percent of the period for which the signal is positive.

To generate 1.5 seconds of a 50 Hz sawtooth (respectively square) wave with a sample rate of 10 kHz, use:

fs = 10000;t = 0:1/fs:1.5;x1 = sawtooth(2*pi*50*t);x2 = square(2*pi*50*t);subplot(211),plot(t,x1), axis([0 0.2 -1.2 1.2])xlabel('Time (sec)');ylabel('Amplitude');title('Sawtooth Periodic Wave');subplot(212)plot(t,x2)axis([0 0.2 -1.2 1.2]);xlabel('Time (sec)');ylabel('Amplitude');title('Square Periodic Wave');


Aperiodic Waveforms

To generate triangular, rectangular and Gaussian pulses, the toolbox offers the tripuls, rectpuls and gauspuls functions.

The tripuls function generates a sampled aperiodic, unity-height triangular pulse centered about t = 0 and with a default width of 1.

The rectpuls function generates a sampled aperiodic, unity-height rectangular pulse centered about t = 0 and with a default width of 1. Note that the interval of non-zero amplitude is defined to be open on the right, that is, rectpuls(-0.5) = 1 while rectpuls(0.5) = 0.

To generate 2 seconds of a triangular (respectively rectangular) pulse with a sample rate of 10 kHz and a width of 20 ms, use:

fs = 10000;t = -1:1/fs:1;x1 = tripuls(t,20e-3);x2 = rectpuls(t,20e-3);subplot(211)plot(t,x1)axis([-0.1 0.1 -0.2 1.2])xlabel('Time (sec)');ylabel('Amplitude');title('Triangular Aperiodic Pulse');subplot(212)plot(t,x2)axis([-0.1 0.1 -0.2 1.2])xlabel('Time (sec)');ylabel('Amplitude');title('Rectangular Aperiodic Pulse');hgcf = gcf;hgcf.Color = [1,1,1];


The gauspuls function generates a Gaussian-modulated sinusoidal pulse with a specified time, center frequency, and fractional bandwidth.

The sinc function computes the mathematical sinc function for an input vector or matrix. The sinc function is the continuous inverse Fourier transform of the rectangular pulse of width 2*pi and height 1.

Generate a 50 kHz Gaussian RF pulse with 60% bandwidth, sampled at a rate of 1 MHz. Truncate the pulse where the envelope falls 40 dB below the peak:

tc = gauspuls('cutoff',50e3,0.6,[],-40);t1 = -tc : 1e-6 : tc;y1 = gauspuls(t1,50e3,0.6);


Generate the sinc function for a linearly spaced vector:

t2 = linspace(-5,5);y2 = sinc(t2);


subplot(211)plot(t1*1e3,y1);xlabel('Time (ms)');ylabel('Amplitude');title('Gaussian Pulse');subplot(212),plot(t2,y2);xlabel('Time (sec)');ylabel('Amplitude');title('Sinc Function');hgcf = gcf;hgcf.Color = [1,1,1];


Swept-Frequency Waveforms

The toolbox also provides functions to generate swept-frequency waveforms such as the chirp function. Two optional parameters specify alternative sweep methods and initial phase in degrees. Below are several examples of using the chirp function to generate linear or quadratic, convex and concave quadratic chirps.

Generate a linear chirp:

t = 0:0.001:2;                 % 2 secs @ 1kHz sample rateylin = chirp(t,0,1,150);       % Start @ DC, cross 150Hz at t=1sec


Generate a quadratic chirp:

t = -2:0.001:2;                % +/-2 secs @ 1kHz sample rateyq = chirp(t,100,1,200,'q');   % Start @ 100Hz, cross 200Hz at t=1sec


Compute and display the spectrograms

subplot(211)spectrogram(ylin,256,250,256,1E3,'yaxis');title('Linear Chirp')subplot(212)spectrogram(yq,128,120,128,1E3,'yaxis');title('Quadratic Chirp')hgcf = gcf;hgcf.Color = [1,1,1];


Generate a convex quadratic chirp.

t = -1:0.001:1;                % +/-1 second @ 1kHz sample ratefo=100;f1=400;                % Start at 100Hz, go up to 400Hzycx = chirp(t,fo,1,f1,'q',[],'convex');


Generate a concave quadratic chirp:

t = -1:0.001:1;                % +/-1 second @ 1kHz sample ratefo=400;f1=100;                % Start at 400Hz, go down to 100Hzycv=chirp(t,fo,1,f1,'q',[],'concave');


Compute and display the spectrograms

subplot(211)spectrogram(ycx,256,255,128,1000,'yaxis');title('Convex Chirp')subplot(212)spectrogram(ycv,256,255,128,1000,'yaxis');title('Concave Chirp')hgcf = gcf;hgcf.Color = [1,1,1];


Another function generator is the vco (Voltage Controlled Oscillator) which generates a signal oscillating at a frequency determined by the input vector. Let's look at two examples using vco with an triangle and rectangle input.

Generate 2 seconds of a signal sampled at 10kHz whose instantaneous frequency is a triangle (respectively a rectangle) function of time:

fs = 10000;t = 0:1/fs:2;x1 = vco(sawtooth(2*pi*t,0.75),[0.1 0.4]*fs,fs);x2 = vco(square(2*pi*t),[0.1 0.4]*fs,fs);


Plot the spectrograms of the generated signals:

subplot(211)spectrogram(x1,kaiser(256,5),220,512,fs,'yaxis');title('VCO Triangle')subplot(212)spectrogram(x2,256,255,256,fs,'yaxis')title('VCO Rectangle')hgcf = gcf;hgcf.Color = [1,1,1];


Pulse Trains

To generate pulse trains, we can use the pulstran function. Below, we'll showcase two examples on how to use this function.

Construct a train of 2 GHz rectangular pulses sampled at a rate of 100 GHz at a spacing of 7.5nS.

fs = 100E9;                    % sample freqD = [2.5 10 17.5]' * 1e-9;     % pulse delay timest = 0 : 1/fs : 2500/fs;        % signal evaluation timew = 1e-9;                      % width of each pulseyp = pulstran(t,D,@rectpuls,w);


Generate a periodic Gaussian pulse signal at 10 kHz, with 50% bandwidth. The pulse repetition frequency is 1 kHz, sample rate is 50 kHz, and pulse train length is 10msec. The repetition amplitude should attenuate by 0.8 each time. The example uses a function handle to refer to the generator function.

T = 0 : 1/50E3 : 10E-3;D = [0 : 1/1E3 : 10E-3 ; 0.8.^(0:10)]';Y = pulstran(T,D,@gauspuls,10E3,.5);


subplot(211)plot(t*1e9,yp);axis([0 25 -0.2 1.2]);xlabel('Time (ns)');ylabel('Amplitude');title('Rectangular Train');subplot(212)plot(T*1e3,Y)xlabel('Time (ms)');ylabel('Amplitude');title('Gaussian Pulse Train');hgcf = gcf;hgcf.Color = [1,1,1];




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Processing MATLAB课程 processI Process cation MATLAB课程 代码示例 SignalProcessingandCommunications SignalGenerationandVisualization


https://www.cda.cn/?seo-luntan
高薪就业·数据科学人才·16年教育品牌

沙发
我有我的love 在职认证  发表于 2016-3-11 14:16:35
MATLAB课程,好赞!!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-2 01:21