Sie sind auf Seite 1von 12

% WAP to generate constant envelope PSk waveform using equation amplitude % normalised to unity.

clear all; clc; % DEFINING PARAMETERS M=8; E=1; T=4*pi; t=0:0.1:T; fc=0.5; % GENERATING SIGNAL OF DIFFERENT PHASE for i = 1:M m = i-1; u = power(2*E/T,0.5)*cos(2*pi*fc*t + 2*pi*m/M); subplot(8,1,i);plot(t,u,'r'); axis([0,4*pi,-0.8,0.8]) xlabel('time, t --->') ylabel('signal u(t) --->') end

% WAP to generate constant envelope QASK * QPSK waveform using equation amplitude % normalised to unity. clear all; clc; % DEFINING PARAMETERS M=4; N=22; % Generating Symbols x=randint(N,1,M); % Generating QPSK and QASK Modulated Signals t1= pskmod(x,M); t2= qammod(x,M); % Scatter Plot of QPSK & QASK Signals scatterplot(t1); scatterplot(t2); %Adding Additive White Noise Gaussian Noise Channel s1=awgn(t1,5); s2=awgn(t2,5); %Demodulation of Signals r1=pskdemod(s1,M); r2=qamdemod(s2,M); % Calculation of Numner of Error and Error Rate [num_err1,err_rate1] = symerr(x,r1) [num_err2,err_rate2] = symerr(x,r2)

OUTPUT: num_err1 = 1 err_rate1 = 0.0455 num_err2 = 1

err_rate2 = 0.0455 >>

% WRITE A PROGRAM TO CALCULATE AND DRAW THE GRAPH OF PROBABILITY OF ERROR VERSUS SNR clc clear all SNR = 1:25; M=16; N=log2(M);

% BPSK, QPSK, MPSK Pe1 = 0.5 * erfc(sqrt(SNR));

% M - ARY PSK x=sin(pi/M); Pe2 = erfc(sqrt(N*SNR*(x^2)));

% 16 QAM Pe3 = 2 * erfc(sqrt(SNR));

plot(SNR,Pe1,'*-',SNR,Pe2,'+-',SNR,Pe3,'--'); legend('BPSK, QPSK, MSK', 'M- ARY PSK', '16 QAM');axis([0,25,0,1]);grid on; title('Graph of Pe versus SNR'); xlabel('SNR ---->'); ylabel('Probability of Error, Pe ----->') gtext('SNR of M- ARY PSK'); gtext('SNR of 16 QAM'); gtext('SNR of BPSK, QPSK, MSK')

% WAP TO GENERATE UNIPOLAR, POLAR, BIPOLAR, RZ, NRZ WAVEFORMS clear all clc T=2; N=5; b = randint(1,N); k=1; for i = 1:N d(1,k:k+1)=[b(1,i),b(1,i)]; j=k+2; k=j; end t=1:2*N; subplot(6,1,1) stairs(t,d) title('Data Stream Waveform'); xlabel('t ---->'); ylabel('f(t) on; axis([1,2*N,-2,2]) %UNIPOLAR Baseband Waveform for i = 1:2*N if d(1,i)==1 f(1,i) = 1; else f(1,i) =0; end end t=1:2*N; subplot(6,1,2) stairs(t,f) title('UNIPOLAR Waveform'); axis([1,2*N,-2,2])

--->');grid

xlabel('t ---->'); ylabel('f(t)

--->');grid on;

%BIPOLAR Baseband Waveform for i = 1:2*N if d(1,i)==1 f(1,i) = 1; else f(1,i) =-1; end end t=1:2*N; subplot(6,1,3) stairs(t,f) title('BIPOLAR Waveform'); xlabel('t ---->'); ylabel('f(t) axis([1,2*N,-2,2])

--->');grid on;

%NRZ Baseband Waveform y1=[-1,1]; y2=[1,-1]; k=1; for i =1:N if b(1,i)==1 f(1,k:k+1) = y1; else f(1,k:k+1) = y2; end j=k+2; k=j;

end t=1:2*N; subplot(6,1,4) stairs(t,f) title('NRZ Waveform'); xlabel('t ---->'); ylabel('f(t) axis([1,2*N,-2,2])

--->');grid on;

%Unipolar RZ Baseband Waveform y1=[1,0]; y2=[0,1]; k=1; for i =1:N if b(1,i)==1 else f(1,k:k+1) = y1;

f(1,k:k+1) = y2; end j=k+2; k=j; end t=1:2*N; subplot(6,1,5) stairs(t,f) title('Unipolar RZ Waveform '); xlabel('t ---->'); ylabel('f(t) on; axis([1,2*N,-2,2]) %Bipolar RZ Baseband Waveform y1=[1,0]; y2=[-1,0]; k=1; for i =1:N if b(1,i)==1 else f(1,k:k+1) = y1;

--->');grid

f(1,k:k+1) = y2; end j=k+2;

k=j; end t=1:2*N; subplot(6,1,6) stairs(t,f) title('Bipolar RZ Waveform'); xlabel('t ---->'); ylabel('f(t) on; axis([1,2*N,-2,2])

--->');grid

% WAP to generate constant envelope FSK waveform clear all; clc; % DEFINING PARAMETERS M=8; N=20; freq_sep=3; nsamp=2; Fs=21; % Generating Symbols x=randint(N,1,M) % Generating FSK Modulated Signal t = fskmod(x,M,freq_sep,nsamp,Fs); % Scatter Plot of FSK Signal scatterplot(t); %Adding Additive White Noise Gaussian Noise Channel s=awgn(t,5); % Scatter Plot of AWGN FSK Signal scatterplot(s); %Demodulation of Signals r=fskdemod(s,M,freq_sep,nsamp,Fs) % Scatter Plot of FSK Signal scatterplot(r); % Calculation of Numner of Error and Error Rate [num_err1,err_rate1] = symerr(x,r1)

Das könnte Ihnen auch gefallen