
i need to plot the amplitude of my signals
9 views (last 30 days)
Show older comments
sara jarikji
on 30 Dec 2016
Commented: sara jarikji
on 30 Dec 2016
I don't know what I did wrong:
%variables
Am=5; %message signal amplitude
Ac=10; %message signal amplitude
t=0:0.001:1; %period
Fm=50; %message frequency
Fc=1000; %carrier frequency
%output graph preparation
m=Am*cos(2*pi*Fm*t); %signal equation
c=Ac*cos(2*pi*Fc*t); %carrier equation
%plot m(t) and its amplitude
figure;
plot(t,m);
xlabel('time');
ylabel('m(t)');
figure;
plot(t,abs(m));
xlabel('time');
ylabel('m(t)');
title('amplitude');
%plot c(t) and its amplitude
figure;
plot(t,c);
xlabel('time');
ylabel('c(t)');
figure;
plot(t,abs(c));
xlabel('time');
ylabel('c(t)');
title('amplitude');
%Sketch the magnitude of the multiplication of m(t) with c(t).
y=m.*c;
figure;
plot(t,y);
xlabel('time');
ylabel('y(t)');
figure
plot(t,abs(y));
xlabel('time');
ylabel('y(t)');
title('amplitude');
0 Comments
Accepted Answer
Image Analyst
on 30 Dec 2016
Try not using so many elements - too many to display.
Try this:
clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 15;
%variables
Am=5; %message signal amplitude
Ac=10; %message signal amplitude
t= linspace(0, 0.04, 1500); %period
Fm=50; %message frequency
Fc=1000; %carrier frequency
%output graph preparation
m=Am*cos(2*pi*Fm*t); % Signal equation
c=Ac*cos(2*pi*Fc*t); % Carrier equation
%plot m(t) and its amplitude
subplot(2,3,1);
plot(t,m);
xlabel('time', 'FontSize', fontSize);
ylabel('m(t)', 'FontSize', fontSize);
title('Signal Equation', 'FontSize', fontSize);
% Put x axis in the right place.
ax = gca
ax.XAxisLocation = 'origin'
subplot(2,3,2);
plot(t,abs(m));
xlabel('time', 'FontSize', fontSize);
ylabel('m(t)', 'FontSize', fontSize);
title('Signal Amplitude', 'FontSize', fontSize);
%plot c(t) and its amplitude
subplot(2,3,3);
plot(t,c);
xlabel('time', 'FontSize', fontSize);
ylabel('c(t)', 'FontSize', fontSize);
title('Carrier Equation', 'FontSize', fontSize);
% Put x axis in the right place.
ax = gca
ax.XAxisLocation = 'origin'
subplot(2,3,4);
plot(t,abs(c));
xlabel('time', 'FontSize', fontSize);
ylabel('c(t)', 'FontSize', fontSize);
title('Carrier Amplitude', 'FontSize', fontSize);
% Put x axis in the right place.
ax = gca
ax.XAxisLocation = 'origin'
%Sketch the magnitude of the multiplication of m(t) with c(t).
y=m.*c;
subplot(2,3,5);
plot(t,y);
xlabel('time', 'FontSize', fontSize);
ylabel('m(t) .* c(t)', 'FontSize', fontSize);
title('Multiplication of m(t) with c(t)', 'FontSize', fontSize);
% Put x axis in the right place.
ax = gca
ax.XAxisLocation = 'origin'
subplot(2,3,6);
plot(t,abs(y));
xlabel('time', 'FontSize', fontSize);
ylabel('y(t)', 'FontSize', fontSize);
title('Amplitude of the multiplication', 'FontSize', fontSize);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')

More Answers (1)
Image Analyst
on 30 Dec 2016
Your carrier frequency is 1000 times per second yet you're only taking samples every 1/1000 of a second. Do you see anything wrong with that? Have you ever heard of aliasing?
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!