Plot a Signal Function

9 ビュー (過去 30 日間)
Sina
Sina 2022 年 11 月 7 日
コメント済み: Walter Roberson 2022 年 11 月 7 日
I am trying to plot a signal in Matlab for
-1.5dt1.5:
x(t) = sin(pi*t)rect(t)
where rect(t) is the rect function.
and I am trying to obtain and plot the magnitude of 𝑋(𝑓) the Fourier transform of 𝑥(𝑡) of that.
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 11 月 7 日
dt can be negative? Your difference between time steps can be negative?? (You have a bit of a meaning question about what exactly should happen for the case where dt = 0, where all times are exactly the same.)

サインインしてコメントする。

採用された回答

Sina
Sina 2022 年 11 月 7 日
clear all
close all
clc
fs= 600; %This Sampling Frequency
dt = 0.001;
T = -1.5:dt:1.5;
fs=1/dt;
f=(-1/2:1/length(T):1/2-1/(length(T)*2))*fs;
y=sin(pi*T).*rectangularPulse(T);
yf = fftshift(fft(y));
z=abs(yf);
plot(f, z);
title("Plot for the Signal");
xlabel("Frequency")
ylabel("X(f):the Fourier transform of 𝑥(𝑡)")
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 11 月 7 日
Note that rectangularPulse requires the Symbolic Toolbox

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by