Shruti01
Member level 3
- Joined
- Apr 14, 2010
- Messages
- 67
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,288
- Location
- Mumbai, India
- Activity points
- 1,941
Hello everyone,
I have written a matlab code for BPSK modulation. Here in the program, I have first generated random binary bits. Modulated the bits with BPSK modulation. Added noise to the bpsk modulated signal. My matlab code is as follows:
clc;
close all;
clear all;
no_of_bits=10;
no_of_samples=10;
threshold = 0.5;
A = rand(1,no_of_bits); % Generate a random sequence
for i=1:no_of_bits
if (A(i)>=threshold)
A(i)=1;
else
A(i)=0;
end
end
d = A(1:no_of_bits) % Binary sequence
% BPSK modulation
Tb = 1; % Bit duration
fc = 3/Tb; % Carrier frequency
t1=linspace(0, 1, no_of_samples);
t2=t1/fc;
M=2; % Number of symbols
theta=([0:M-1]*2*pi)/M; % Reference phase values
PhaseOsc1=cos(2*pi*fc*t2)
PhaseOsc2=cos(theta) % Carrier waveform
b = 2*d-1 % Bipolar sequence
for i=1:no_of_bits
for j=1:no_of_samples
b1(j)=b(i)
end
bpskmod=b1.*PhaseOsc1.*PhaseOsc2; % Modulated bpsk waveform
end
noise = randn(1,no_of_samples); % Noise addition
recbpsk = bpskmod + noise;
After running the above program, it gives me following error:
Error in ==> abc1 at 30
bpskmod=b1.*PhaseOsc1.*PhaseOsc2; % Modulated bpsk waveform
Kindly help me in correcting the above error.
I have written a matlab code for BPSK modulation. Here in the program, I have first generated random binary bits. Modulated the bits with BPSK modulation. Added noise to the bpsk modulated signal. My matlab code is as follows:
clc;
close all;
clear all;
no_of_bits=10;
no_of_samples=10;
threshold = 0.5;
A = rand(1,no_of_bits); % Generate a random sequence
for i=1:no_of_bits
if (A(i)>=threshold)
A(i)=1;
else
A(i)=0;
end
end
d = A(1:no_of_bits) % Binary sequence
% BPSK modulation
Tb = 1; % Bit duration
fc = 3/Tb; % Carrier frequency
t1=linspace(0, 1, no_of_samples);
t2=t1/fc;
M=2; % Number of symbols
theta=([0:M-1]*2*pi)/M; % Reference phase values
PhaseOsc1=cos(2*pi*fc*t2)
PhaseOsc2=cos(theta) % Carrier waveform
b = 2*d-1 % Bipolar sequence
for i=1:no_of_bits
for j=1:no_of_samples
b1(j)=b(i)
end
bpskmod=b1.*PhaseOsc1.*PhaseOsc2; % Modulated bpsk waveform
end
noise = randn(1,no_of_samples); % Noise addition
recbpsk = bpskmod + noise;
After running the above program, it gives me following error:
Error in ==> abc1 at 30
bpskmod=b1.*PhaseOsc1.*PhaseOsc2; % Modulated bpsk waveform
Kindly help me in correcting the above error.