www.gusucode.com > phased 案例源码 matlab代码程序 > phased/TransmitRectangularPulseWithPhaseNoiseExample.m
%% Transmit Rectangular Pulse With Phase Noise % This example illustrates adding phase noise to a rectangular pulse waveform having five % pulses. A random phase is added to each sample of the waveform. Compute % the phase of the output waveform and compare the phase to the phase noise % returned when executing the System object(TM). %% % *Note:* This example runs only in R2016b or later. If you are using an earlier % release, replace each call to the function with the equivalent |step| % syntax. For example, replace |myObject(x)| with |step(myObject,x)|. %% % For convenience, set the gain % of the transmitter to 0 dB, the peak power to 1 W, and seed the random % number generator to ensure reproducible results. waveform = phased.RectangularWaveform('NumPulses',5); transmitter = phased.Transmitter('CoherentOnTransmit',false,... 'PhaseNoiseOutputPort',true,'Gain',0,'PeakPower',1,... 'SeedSource','Property','Seed',1000); wf = waveform(); [txtoutput,phnoise] = transmitter(wf); phdeg = rad2deg(phnoise); phdeg(phdeg>180)= phdeg(phdeg>180) - 360; plot(wf) title('Input Waveform') axis([0 length(wf) 0 1.5]) ylabel('Amplitude') grid on %% % subplot(2,1,1) plot(rad2deg(atan2(imag(txtoutput),real(txtoutput)))) title('Phase of the Output') ylabel('Degrees') axis([0 length(wf) -180 180]) grid on subplot(2,1,2) plot(phdeg) title('Phase Noise'); ylabel('Degrees') axis([0 length(wf) -180 180]) grid on %% % The first figure shows the waveform. The phase of each pulse at the input % to the transmitter is zero. In the second figure, the top plot shows the % phase of the transmitter output waveform. The bottom plot shows the phase % added to each sample. Focus on the first 100 samples. The pulse waveform % is equal to 1 for samples 1-50 and 0 for samples 51-100. % The added random phase is a constant -124.7° for samples % 1-100, but this affects the output only when the pulse waveform is % nonzero. In the output waveform, you see that the output waveform has a % phase of -124.7° for samples 1-50 and 0 for samples % 51-100. Examining the transmitter output and phase noise for % samples where the input waveform is nonzero, you can see that the phase % output the System object and the phase of the transmitter output % agree.