mujee
Member level 1
hi guys
i have been asked to show how a square wave is changed to raised cosine for pulse shaping. what i did was generated sequence of rectangular pulses and then passed it through firrcos filter. but teacher now said that i shouldnt be doing it this way
i m supposed to generate a square wave and then from it subtract a cosine wave to get raised cosine wave. i did it but the shape i got was not correct. it was like half rectified sinusoid.
any suggestions?
x=(1:0.1:3); %array for x axis of square wave
r=[1 0 1]; % input wave
k=1:30;k=1;
x2 = pii/9:2*pi; %for sine wave
for i=1:3
if r(i)==1
x(k:k+9)=1; % square pulse generation
y(k:k+9) = sin(x2)+1; %sine pulse generation equal in width to square pulse
k=k+10
elseif r(i)==0
x(k:k+9)=0;
y(k:k+9) = 0;
k=k+10
end
end
stairs(x,'r');
hold on;
stem
figure(2)
t=x-y; %taking difference of two waves to get the required shape
plot(t)
what it does is generate a negative half of sine wave and subtract it from square wave pulse and do nothing if input is zero
the output plot is not correct.
how to correct it.......help plz
i have been asked to show how a square wave is changed to raised cosine for pulse shaping. what i did was generated sequence of rectangular pulses and then passed it through firrcos filter. but teacher now said that i shouldnt be doing it this way
i m supposed to generate a square wave and then from it subtract a cosine wave to get raised cosine wave. i did it but the shape i got was not correct. it was like half rectified sinusoid.
any suggestions?
x=(1:0.1:3); %array for x axis of square wave
r=[1 0 1]; % input wave
k=1:30;k=1;
x2 = pii/9:2*pi; %for sine wave
for i=1:3
if r(i)==1
x(k:k+9)=1; % square pulse generation
y(k:k+9) = sin(x2)+1; %sine pulse generation equal in width to square pulse
k=k+10
elseif r(i)==0
x(k:k+9)=0;
y(k:k+9) = 0;
k=k+10
end
end
stairs(x,'r');
hold on;
stem
figure(2)
t=x-y; %taking difference of two waves to get the required shape
plot(t)
what it does is generate a negative half of sine wave and subtract it from square wave pulse and do nothing if input is zero
the output plot is not correct.
how to correct it.......help plz