%% Convert FM Signal to AM Signal
% Create an FM wave on a 100 Hz carrier signal sampled at 1.5 kHz.

Fc = 1e2;   % Carrier
Fs = 1.5e3; % Sample rate
sinewave = dsp.SineWave('Frequency',10,...
                            'SamplesPerFrame',1e3,...
                            'SampleRate',Fs);
%% 
% Convert the FM signal to an AM signal.
%%
ts = dsp.TimeScope(2,...
                      'TimeSpan',0.3,...
                      'BufferLength',10*Fs,...
                      'SampleRate',Fs,...
                      'ShowGrid',true,...
                      'YLimits',[-1.5 1.5],...
                      'LayoutDimensions',[2 1]);
                  
df = dsp.Differentiator;
    
tic
while toc<2.2
    x = step(sinewave);
    fm_y = modulate(x,Fc,Fs,'fm');
    am_y = step(df,fm_y);
    step(ts,fm_y,am_y);
end
    
release(df);
release(ts);

%% 
% Copyright 2012 The MathWorks, Inc.