Sunteți pe pagina 1din 4

function [bits,THcode,Stx,ref]=cp0201_transmitter_2PPM_TH

Pow = -30; fc = 50e9; numbits = 1; Ts = 3e-9; Ns = 1; Tc = 1e-9; Nh = 3; Np = 5; Tm = 0.5e-9; tau = 0.25e-9; dPPM = 0.5e-9;

% Average transmitted power (dBm) % sampling frequency % number of bits generated by the source % frame time, i.e. average pulse % repetition period [s] % number of pulses per bit % chip time [s] % cardinality of the Time Hopping code % periodicity of the Time Hopping code % pulse duration [s] % shaping factor for the pulse [s] % time shift introduced by the PPM [s]

G = 1; % G=0 -> no graphical output % G=1 -> graphical output % ---------------------------------------% Step One - Simulating Transmission Chain % ---------------------------------------% binary source bits = cp0201_bits(numbits); % repetition coder repbits = cp0201_repcode(bits,Ns); % Time Hopping code THcode = cp0201_TH(Nh,Np); % Pulse Position Modulation + TH [PPMTHseq,THseq] = ... cp0201_2PPM_TH(repbits,fc,Tc,Ts,dPPM,THcode); % Shaping filter power = (10^(Pow/10))/1000;

% % Ex = power * Ts; % w0 = cp0201_waveform(fc,Tm,tau);% % wtx = w0 .* sqrt(Ex); % Sa = conv(PPMTHseq,wtx); % % Sb = conv(THseq,wtx); %

average transmitted power (watt) energy per pulse Energy Normalized pulse waveform pulse waveform Output of the filter (with modulation) Output of the filter

% % Output generation L = (floor(Ts*fc))*Ns*numbits; Stx = Sa(1:L); ref = Sb(1:L); % --------------------------% Step Two - Graphical Output % --------------------------if G F = figure(1); set(F,'Position',[32 223 951 420]);

(without modulation)

tmax = numbits*Ns*Ts; time = linspace(0,tmax,length(Stx)); P = plot(time,Stx); set(P,'LineWidth',[2]); ylow=-1.5*abs(min(wtx)); yhigh=1.5*max(wtx); axis([0 tmax ylow yhigh]); AX=gca; set(AX,'FontSize',12); X=xlabel('Time [s]'); set(X,'FontSize',14); Y=ylabel('Amplitude [V]'); set(Y,'FontSize',14); for j = 1 : numbits tj = (j-1)*Ns*Ts; L1=line([tj tj],[ylow yhigh]); set(L1,'Color',[0 0 0],'LineStyle', ... '--','LineWidth',[2]); for k = 0 : Ns-1 if k > 0 tn = tj + k*Nh*Tc; L2=line([tn tn],[ylow yhigh]); set(L2,'Color',[0.5 0.5 0.5],'LineStyle', ... '-.','LineWidth',[2]); end for q = 1 : Nh-1 th = tj + k*Nh*Tc + q*Tc; L3=line([th th],[0.8*ylow 0.8*yhigh]); set(L3,'Color',[0 0 0],'LineStyle', ... ':','LineWidth',[1]); end end end end % end of graphical output

path(path, 'C:\MATLAB7\l1magic-1.1\Optimization');

path(path, 'C:\MATLAB7\l1magic-1.1\Data'); %number of samples per period s=4; %RF frequency f=4e9; %pulse repetition frequency prf=3e-9; %sampling frequency fs=50e9; %Total Simulation time T=30e-9; t=0:1/fs:T; %generating pulse train %x=pulstran(t,15e-9,'gauspuls',f,0.5); x=ref; %length of the signal N=length(x); %Number of random observations to take K=90; figure; subplot(2,1,1); plot(time,x) grid on; xlabel('Time'); ylabel('Amplitude'); title(sprintf('Original Signal, UWB Pulse')); %taking Discrete time Fourier Transform of the signal xf=fft(x); xfmag=10*log10(abs(xf)); subplot(2,1,2); plot(abs(xf)) grid on; xlabel('Samples'); ylabel('Amplitude'); title('Discrete Fourier Transform of UWB pulse');

%creating dft matrix B=dftmtx(N); Binv=inv(B); %Selecting random rows of the DFT matrix

q=randperm(N); %creating measurement matrix A=B(q(1:K),:); %taking random frequency measurements y=(A*x'); % Calculating Initial guess x0=A'*y; %Running the recovery Algorithm tic xp=l1eq_pd(x0,A,[],y,1e-5); toc figure; subplot(2,1,1) plot(time,x) grid on; xlabel('Time'); ylabel('Amplitude'); title(sprintf('Original Signal, UWB Pulse'));

subplot(2,1,2) plot(time,real(xp),'r') grid on; xlabel('Time'); ylabel('Amplitude'); title(sprintf('Recovered UWB Pulse Signal with %d random samples',K));

S-ar putea să vă placă și