MSII_Cvičení_4 Práce se signály: řízené generátory modulace (AM, FM, PM, PWM) >> t=0:0.001:2; >> y=chirp(t,0,1,2); % Start at 0Hz, go up to 2Hz, at t=1 sec >> plot(t,y) 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 Př.: 2 >> t=0:0.001:2; y=chirp(t,0,1,2,'quadratic'); plot(t,y) 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 Př.: 3. >> >> >> >> >> x=zeros(1,1000); x(1,[1:500])=-0.8; x(1,[501:1000])=0.8; y=vco(x,2,90); plot(y) 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 100 200 300 400 500 600 700 800 900 1000 Př.: 4. >> >> >> >> t=-3*pi:6*pi/1000:3*pi; y=sinc(t); plot(t,y) grid on 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -10 -8 -6 -4 -2 0 2 4 6 8 10 MODULATE Signal modulation for communications simulations. Y = MODULATE(X,Fc,Fs,METHOD,OPT) modulates the message signal X with a carrier frequency Fc and sampling frequency Fs, using the modulation scheme in METHOD. OPT is an extra sometimes optional parameter whose purpose depends on the modulation scheme you choose. Fs must satisfy Fs > 2*Fc + BW, where BW is the bandwidth of the modulated signal. METHOD MODULATION SCHEME 'am', Amplitude modulation, double side-band, suppressed carrier 'amdsb-sc' OPT not used. 'amdsb-tc' Amplitude modulation, double side-band, transmitted carrier OPT is a scalar which is subtracted from X prior to multiplication by the carrier cosine. It defaults to min(min(X)) so the offset message signal is positive and has a minimum value of zero. 'amssb' Amplitude modulation, single side-band OPT not used. 'fm' Frequency modulation OPT is a scalar which specifies the constant of frequency modulation kf. kf = (Fc/Fs)*2*pi/max(max(abs(X))) by default for a maximum frequency excursion of Fc Hertz. 'pm' Phase modulation OPT is a scalar which specifies the constant of phase modulation kp. kp = pi/max(max(abs(x))) by default for a maximum phase excursion of +/-pi radians. 'pwm' Pulse width modulation If you let OPT = 'centered', the pulses are centered on the carrier period rather than being "left justified". 'ppm' Pulse position modulation OPT is a scalar between 0 and 1 which specifies the pulse width in fractions of the carrier period. It defaults to .1. 'qam' Quadrature amplitude modulation OPT is a matrix the same size as X which is modulated in quadrature with X. If X is a matrix, its columns are modulated. [Y,T] = MODULATE(...) returns a time vector the same length as Y. See also demod, vco in the signal Processing Toolbox, and PAMDEMOD, QAMDEMOD, GENQAMDEMOD, FSKDEMOD, PSMDEMOD, MSKDEMOD in the Communications Toolbox. Reference page in Help browser doc modulate Př 5. Modulace AM fc=1000; fs=4000;t=0:1/fs:1; >> x=sin(2*pi*50*t); >> y=modulate(x,fc,fs,'am'); >> plot(t([1:160]),y([1:160])) 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 0.005 0.01 0.015 0.02 >> hold on >> plot(t([1:160]),x([1:160]),'r') 0.025 0.03 0.035 0.04 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 Př. 6.: FM fc=400; fs=4000;t=0:1/fs:1; >> x=1-10*sin(2*pi*20*t); >> y=modulate(x,fc,fs,'fm'); >> subplot(2,1,1), plot(t([1:400]),x([1:400]),'r') subplot(2,1,2), plot(t([1:400]),y([1:400])) 15 10 5 0 -5 -10 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 1 0.5 0 -0.5 -1 Další modulace fc=100;fs=2000; x=[0.1 0.3 0.5 0.7 0.9]; y=modulate(x,fc,fs,'pwm');plot(y), axis([-Inf Inf 0 1.1) y=modulate(x,fc,fs,'pwm');plot(y), axis([-Inf Inf 0 1.1]) fc=400; fs=4000;t=0:1/fs:1; x=0.5-0.5*sin(2*pi*20*t); y=modulate(x,fc,fs,'pwm'); subplot(2,1,1), plot(t([1:400]),x([1:400]),'r') subplot(2,1,2), plot(t([1:400]),y([1:400])) axis([-Inf Inf -0.1 1.1]) clc fc=100;fs=2000; x=[0.1 0.3 0.5 0.7 0.9]; y=modulate(x,fc,fs,'pwm');plot(y), axis([-Inf Inf y=modulate(x,fc,fs,'ppm');plot(y), axis([-Inf Inf x=[0.1 0.3 0.5 0.7 0.9]; y=modulate(x,fc,fs,'ppm',0.3);plot(y), axis([-Inf clc fc=100;fs=2000; x=[0.1 0.5 0.7 0.5 0.1]; y=modulate(x,fc,fs,'ppm',0.3);plot(y), axis([-Inf 0 1.1]) 0 1.1]) Inf 0 1.1]) Inf 0 1.1])