fm = 1;
fs = 50*fm;
time = 10;
t = (0:1/fs:time);

m = cos(2*pi*fm*t);
%m = sawtooth(2*pi*fm*t);
%m = square(2*pi*fm*t);

fc = 50;
deltaf = 20;
%deltap = 0.2*deltaf;
%deltap = deltaf/fm;
deltap = 1;

[x_fm, tout_fm] = fmmod_jvk1(m, t, fc, deltaf);
[x_pm, tout_pm] = pmmod_jvk1(m, t, fc, deltap);

figure(1)
subplot(3,1,1)
plot(t,m)
xlabel('Time (sec)')
title('Message')
subplot(3,1,2)
plot(tout_fm,x_fm)
xlabel('Time (sec)')
title('FM')
subplot(3,1,3)
plot(tout_pm,x_pm)
xlabel('Time (sec)')
title('PM')


figure(2)
subplot(3,1,1)
plotspec_v3(m,1/fs)
title('Message Mag Spectrum')
subplot(3,1,2)
plotspec_v3(x_fm,tout_fm(2)-tout_fm(1))
title('FM Mag Spectrum')
subplot(3,1,3)
plotspec_v3(x_pm,tout_pm(2)-tout_pm(1))
title('PM Mag Spectrum')

