Plotting Discrete Time Functions

537 visualizaciones (últimos 30 días)
Bradley Johnson
Bradley Johnson el 22 de Sept. de 2020
Respondida: Austin Holmes el 11 de Nov. de 2021
I need to plot 5 cos(π n /6 - π/2) as a discrete tim signal. But I am not getting the proper result.
n = [-5:0.001:5];
y = 5*cos(pi*(n/2)-(pi/2));
stem(n,y);
What am I missing from this code to get the discrete time signals?

Respuestas (2)

Austin Holmes
Austin Holmes el 11 de Nov. de 2021
The original poster asked for the discrete time signal not the continuous time signal. A discrete time signal just means sampling your continuous signal at discrete time intervals.
The simplest way this can be done is by increasing your step in n.
n = [-5:0.25:5];
y = 5*cos(pi*(n/2)-(pi/2));
stem(n,y);
The proper way to do this would be determining a sampling rate and implementing it in your code.

Freedom TSOKPO
Freedom TSOKPO el 23 de Sept. de 2020
I've just began with Matlab and I don't even know the function stem.
But I think this code can do it
clear all; clc;
n = -5:0.001:5;
y = 5*cos((n-1)*pi/2); %5*cos(pi*(n/2)-(pi/2));
figure
% axis([-6 6 -4 4]);
plot(n,y);

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by