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 Center および File ExchangeSpectral Measurements についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by