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 all,
I have written a code for qpsk modulation in matlab. My code is as follows:
clc;
close all;
d = [0 1 1 1 0 1 0 0 1 0] % Data sequence
b = 2*d-1 % Convert unipolar to bipolar
Tb = 1 % Bit duration
fc = 3/Tb % Carrier frequency
Es = Tb/2 % This will result into unit amplitude waveforms
t = linspace(0, 10, 1000); % Discrete time samples between 0 and 10*Tb(1000 samples)
N = length(t) % Number of samples
Nsb = N/length(d) % Number of samples per bit
dd = repmat(d', 1, Nsb); % Replicate each bit Nsb times
bb = repmat(b', 1, Nsb);
dw = dd'; % Represent dw into a column vector(column by column)
dw = dw)'; % Represent dw into a row vector(row by row)
bw = bb'; % Represent bw into a column vector(column by column)
bw = bw)'; % Data sequence samples
o = b(1:2:end) %separating odd bits
e = b(2:2:end) %separating even bits
oo = repmat(o', 1, Nsb)
ee = repmat(e', 1, Nsb)
ow = oo'
ow = ow)'
ew = ee'
ew = ew)'
inPhaseOsc = 1/sqrt(2*Es/Tb)*cos(2*pi*fc*t)
quadPhaseOsc = 1/sqrt(2*Es/Tb)*sin(2*pi*fc*t)
qpskModulated = ow.*quadPhaseOsc + ew.*inPhaseOsc;
% Plotting the waveforms
subplot(4,1,1);
plot(t,dw);axis([0 10 -1.5 1.5])
subplot(4,1,2);
plot(t,bw);axis([0 10 -1.5 1.5])
subplot(4,1,3);
plot(t,inPhaseOsc);axis([0 10 -1.5 1.5])
subplot(4,1,4);
plot(t,quadPhaseOsc);axis([0 10 -1.5 1.5])
subplot(4,1,5);
plot(t,qpskModulated);axis([0 10 -1.5 1.5])
When I run the program, it gives me following error.
Error using ==> times
Matrix dimensions must agree.
Error in ==> Untitled5 at 30
qpskModulated = ow.*quadPhaseOsc + ew.*inPhaseOsc;
Kindly help.
I have written a code for qpsk modulation in matlab. My code is as follows:
clc;
close all;
d = [0 1 1 1 0 1 0 0 1 0] % Data sequence
b = 2*d-1 % Convert unipolar to bipolar
Tb = 1 % Bit duration
fc = 3/Tb % Carrier frequency
Es = Tb/2 % This will result into unit amplitude waveforms
t = linspace(0, 10, 1000); % Discrete time samples between 0 and 10*Tb(1000 samples)
N = length(t) % Number of samples
Nsb = N/length(d) % Number of samples per bit
dd = repmat(d', 1, Nsb); % Replicate each bit Nsb times
bb = repmat(b', 1, Nsb);
dw = dd'; % Represent dw into a column vector(column by column)
dw = dw)'; % Represent dw into a row vector(row by row)
bw = bb'; % Represent bw into a column vector(column by column)
bw = bw)'; % Data sequence samples
o = b(1:2:end) %separating odd bits
e = b(2:2:end) %separating even bits
oo = repmat(o', 1, Nsb)
ee = repmat(e', 1, Nsb)
ow = oo'
ow = ow)'
ew = ee'
ew = ew)'
inPhaseOsc = 1/sqrt(2*Es/Tb)*cos(2*pi*fc*t)
quadPhaseOsc = 1/sqrt(2*Es/Tb)*sin(2*pi*fc*t)
qpskModulated = ow.*quadPhaseOsc + ew.*inPhaseOsc;
% Plotting the waveforms
subplot(4,1,1);
plot(t,dw);axis([0 10 -1.5 1.5])
subplot(4,1,2);
plot(t,bw);axis([0 10 -1.5 1.5])
subplot(4,1,3);
plot(t,inPhaseOsc);axis([0 10 -1.5 1.5])
subplot(4,1,4);
plot(t,quadPhaseOsc);axis([0 10 -1.5 1.5])
subplot(4,1,5);
plot(t,qpskModulated);axis([0 10 -1.5 1.5])
When I run the program, it gives me following error.
Error using ==> times
Matrix dimensions must agree.
Error in ==> Untitled5 at 30
qpskModulated = ow.*quadPhaseOsc + ew.*inPhaseOsc;
Kindly help.