Plotting Discrete Time Functions

조회 수: 537 (최근 30일)
Bradley Johnson
Bradley Johnson 2020년 9월 22일
답변: Austin Holmes 2021년 11월 11일
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?

답변 (2개)

Austin Holmes
Austin Holmes 2021년 11월 11일
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 2020년 9월 23일
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);

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by