MATLAB: Amplitude modulation & demodulation signal

modulationsignaldemodulationsignal

hey there, can anybody help me .. i had run the code but the graph doesnt want to appear..anybody can help me..thank you
t=linspace(0,0.02,10000);
fc=5000;
fm=200;
fs=40000;
Am=5;
Ac=10;
m=(Am/Ac);
wc=(2*pi*fc*t);
wm=(2*pi*fm*t);
ec=(Ac*sin(wc));
em=(Am*sin(wm));
y=(Ac*(l+m*sin(wm).*sin(wc)));
d=(y.*ec);
dl=(conv(d,exp(-t/0.000795)));
l=10000;
subplot(4,1,1),plot(t(1:1),em(1:1))
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('MODULATING SIGNAL');
subplot(4,1,2),plot(t(1:1),ec(1:1))
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('CARRIER SIGNAL');
subplot(4,1,3),plot(t(1:1),ec(1:1))
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('MODULATED SIGNAL');
subplot(4,1,4),plot(t(1:1),ec(1:1))
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('DEMODULATED SIGNAL');

Best Answer

... the graph doesnt want to appear.
It wants to appear, however you are not letting it!
The (1:1) subscript reference addresses only one point, that being 1, and since the plot function plots between pairs of points, nothing appears. (Note that ‘l’ is in the wrong place in your code. Put it before it is first used.)
Try this:
subplot(4,1,1),plot(t,em)
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('MODULATING SIGNAL');
subplot(4,1,2),plot(t,ec)
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('CARRIER SIGNAL');
subplot(4,1,3),plot(t,ec)
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('MODULATED SIGNAL');
subplot(4,1,4),plot(t,ec)
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('DEMODULATED SIGNAL');
You likely copied the plot calls and pasted them to the subplot calls, so you are plotting the same vector the last three times. You might want to check that.
Related Question