%   Problem 6.4
%   The waveforms in problem 6.1 are reconstructed
%   using a square characteristic pulse.
N=input('N= ')
M=input('M= ')
A=input('A= ')
phi=input('phi= ')
n=1:N;
v=A*cos(M*2*pi*n/N+phi);
%   Get the characteristic pulse
for k=1:20
    pulse(k)=p2(k);
end
Vexpand=zeros((N-1)*10,1);
for m=1:N
    Vexpand((m-1)*10+1)=v(m);
end
Vr=conv(pulse,Vexpand);

%   Ignoring the first 10 points
As=num2str(A);
As = ['A = ' As];
Ns = ['N = ' num2str(N)];
Ms = ['M = ' num2str(M)];
phis=['phi = ' num2str(phi)];

%   Plot all but the first and last 10 points
plot(10:length(Vr)-10,Vr(10:length(Vr)-10)),legend(As,Ns,Ms,phis)

   