clc;
clear all;
%Baseband transmitted signal generation
pulse_width=3.33e-8;
prf=150e3;
sample_rate=60e6;
pri=0.00667;
bandWidth = 30e6; % Bandwidth of the pulse (Hz)
IPhase = 0; % Initial phase in degrees of IComponent
QPhase = 90; % Initial phase in degrees of QComponent
tVector = 0:1/sample_rate:pulse_width; % Vector to generate ideal pulse
IComponent = chirp(tVector,-bandWidth/2,tVector(end), bandWidth/2,'linear',IPhase);
QComponent = chirp(tVector,-bandWidth/2,tVector(end), bandWidth/2,'linear',QPhase);
IQData = IComponent + 1i*QComponent;
% Normalizing the amplitude of the signal.
scale = max(max(abs(real(IQData))), max(abs(imag(IQData))));
idealPulse = IQData / scale;
% Pad the pulse with zeros for the off cycle of the pulse.
offPulse = 0:1/sample_rate:((pri-pulse_width)/2);
idealSpacedPulse = [offPulse idealPulse offPulse];
figure(1); hold on;
plot((1:length(idealSpacedPulse))/sample_rate, real(idealSpacedPulse),'b')
plot((1:length(idealSpacedPulse))/sample_rate, imag(idealSpacedPulse),'g')
plot((1:length(idealSpacedPulse))/sample_rate, abs(idealSpacedPulse),':r','linewidth',2)
title('One cycle of rect pulse waveform')
xlabel('Time (s)')
ylabel('Magnitude (V)')
legend('I component','Q component','Envelope')
axis tight; axisLimits = axis; axis([axisLimits(1:2) 1.2*(axisLimits(3:4))])