Sinusoidal Signals on Matlab

Posted by Nino Lau on March 13, 2019

Problem 1

Question Description

Write a Matlab program to plot a continuous-time sinusoidal signal and its sampled version, and verify. (You need to use the hold function to keep both plots.)

Matlab Implementation


% f = 3Hz
T=1;
t=0:0.01:T;
F=sin(2*pi*t*f);
plot(t,F,'LineWidth',1);
title('Sinusoidal Signal','FontSize',18);
xlabel('t');
ylabel('F(t)');
hold on;

% f = 7Hz
f=7; 
T=1;
t=0:0.01:T;
F=sin(2*pi*t*f);
plot(t,F,'LineWidth',1);
title('Sinusoidal Signal','FontSize',18);
xlabel('t');
ylabel('F(t)');
hold on;

% f = 13Hz
f=13; 
T=1;
t=0:0.01:T;
F=sin(2*pi*t*f);
plot(t,F,'LineWidth',1);
title('Sinusoidal Signal','FontSize',18);
xlabel('t');
ylabel('F(t)');
hold off;

Experiment Results

Problem 2

Question Description

Using the program developed in the previous problem, verify experimentally that the family of continuous-time sinusoids.

Matlab Implementation

% f = 3Hz
f0 = 2;
FT = 50;
d = 1;
A = 1;
k = input('k = ');
omega0 = 2*pi*f0;
omegaT = 2*pi*FT;

% Signal k = -1
t = 0:0.001:1;
g1 = A*cos(omega0*t+d+k*omegaT*t);
subplot(2,1,1)
plot(t,g1,'b-')
xlabel('t');
ylabel('amp');
hold
n = 0:1:FT;
gs = A*cos(omega0*n/FT+d+k*omegaT*n/FT);
plot(n/FT,gs,'ro');
hold 

% Signal k = 2
k = input('k = ');
t = 0:0.001:1;
g1 = A*cos(omega0*t+d+k*omegaT*t)
subplot(2,1,2)
plot(t,g1,'b-')
xlabel('t')
ylabel('amp')
hold
n = 0:1:FT;
gs = A*cos(omega0*n/FT+d+k*omegaT*n/FT);
plot(n/FT,gs,'ro');
hold off

Experiment Results

From the two subplots, we can see that the shapes of red circles are same. Thus, the family of continuous-time sinusoids are verified.