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,
I have written a matlab code for ask modulation and demodulation. I have taken 1 bit at a time, modulated tat bit, added noise to it and demodulated that bit to recover the original data bit. I need to modify this code for all the bits present in the data sequence.... I have to repeat the above steps for 10 bits... How to do tat.. kindly help... my code is as follows:
clc;
close all;
clear all;
no_of_bits=10;
no_of_samples=20;
threshold = 0.5;
snr=-3;
Tb = 1; % Bit duration
fc = 3/Tb; % Carrier frequency
t1=linspace(0, 1, no_of_samples);
t2=t1/fc;
w=cos(2*pi*fc*t2);
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
if (d(1)==1)
askmod=d(1).*w;
else
askmod=d(1);
end
a1=askmod % Modulated ask signal
% Noise addition
noise = (10^(-snr/20))*randn(1,no_of_samples);
received = a1 + noise;
% Multipying the received signal with carrier waveform
v = received.*w;
y=v;
z=trapz
if z<0
z=0;
else
z=1;
end
bask=z
I have written a matlab code for ask modulation and demodulation. I have taken 1 bit at a time, modulated tat bit, added noise to it and demodulated that bit to recover the original data bit. I need to modify this code for all the bits present in the data sequence.... I have to repeat the above steps for 10 bits... How to do tat.. kindly help... my code is as follows:
clc;
close all;
clear all;
no_of_bits=10;
no_of_samples=20;
threshold = 0.5;
snr=-3;
Tb = 1; % Bit duration
fc = 3/Tb; % Carrier frequency
t1=linspace(0, 1, no_of_samples);
t2=t1/fc;
w=cos(2*pi*fc*t2);
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
if (d(1)==1)
askmod=d(1).*w;
else
askmod=d(1);
end
a1=askmod % Modulated ask signal
% Noise addition
noise = (10^(-snr/20))*randn(1,no_of_samples);
received = a1 + noise;
% Multipying the received signal with carrier waveform
v = received.*w;
y=v;
z=trapz
if z<0
z=0;
else
z=1;
end
bask=z