How to plot Carrier and Message Signal
66 views (last 30 days)
Show older comments
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171742/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171743/image.png)
The first picture is the equation for carrier signal and the 2nd one is the message signal.
The ampltitudes for both (Ac and Am are 1), and the frequency for the carrier (fc) is given by the user, whereas the frequency for the message (fm) is 0.02.
However, I'm unsure in how to plot these two signals on top of each other. Am I doing the interval for the fplot correctly?
fc = input('carrier frequency')
fm = 0.02 %Hz
Ac = 1;
Am = 1;
Ta = 1/fc; %period for carrier
Tc = 1/fm;
m = @(t) Am*cos(2*pi*fm*t);
S = @(t) Ac*cos(2*pi*fc*t);
subplot(3, 1 ,1);
fplot(S, [0 Ta]);
subplot(3, 1, 2);
fplot(m, [0 Tc]);
0 Comments
Answers (2)
Abraham Boayue
on 2 Apr 2018
Edited: Abraham Boayue
on 2 Apr 2018
Try something like this :
clear variables
close all
fc = input('carrier frequency')
fm = 4 %Hz
Ac = 1;
Am = 1;
Ta = 1/fc; %period for carrier
Tc = 1/fm;
N = 200;
t0 = -2;
t1 = 2;
t = t0:(t1-t0)/(N-1):t1;
m = Am*cos(2*pi*fm*t);
S = Ac*cos(2*pi*fc*t);
plot(t,S,'linewidth',2,'color','r')
hold on
plot(t,m,'linewidth',2,'color','b')
legend('S(t)','M(t)')
a= title('Carrier and Message Signals');
set(a,'fontsize',14);
a= xlabel('t [-2\pi 2\pi]');
set(a,'fontsize',20);
a = ylabel('y');
set(a,'fontsize',20);
a = zlabel('z');
set(a,'fontsize',20);
grid
grid minor
0 Comments
Kalpana
on 17 Jul 2023
fc = input('carrier frequency')
fm = 0.02 %Hz
Ac = 1;
Am = 1;
Ta = 1/fc; %period for carrier
Tc = 1/fm;
m = @(t) Am*cos(2*pi*fm*t);
S = @(t) Ac*cos(2*pi*fc*t);
subplot(3, 1 ,1);
fplot(S, [0 Ta]);
subplot(3, 1, 2);
fplot(m, [0 Tc]);
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!