fs = 8000; % Sampling rate is 8000 samples per second
fc = 300; % Carrier frequency in Hz
t = [0:0.1*fs]'/fs; % Sampling times for 0.1 second
m = sin(20*pi*t); % Representation of the signal
v = ammod(m,fc,fs); % Modulate m to produce v
figure(1)
subplot(2,1,1); plot(t,m); % Plot m on top
subplot(2,1,2); plot(t,v) % Plot v below
mr = amdemod(v,fc,fs); % Demodulate v to produce m
figure(2)
subplot(2,1,1); plot(t,m); % Plot m on top
subplot(2,1,2); plot(t,mr) % Plot mr below