How to code this periodic function?

5 ビュー (過去 30 日間)
Niloufar
Niloufar 2022 年 10 月 31 日
回答済み: Walter Roberson 2022 年 10 月 31 日
I have this periodic function and I want to code it.I don't want to change the period and other parts of code because I calculate the fft of it.How can I do that?
syms x;
Fs = 50;
T = 1/Fs;
L = 100;
t = (0:L-1)*T;
X1 = zeros(1,length(t));
X1(abs(t)<T/4) = 1;
Y1 = fft(X1);
f = Fs*(0:(L-1))/L;

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 10 月 31 日
fft() assumes that the input is a subset of a periodic signal. For fft() purposes you can generate a positive integer number of cycles of samples and fft() that. Nothing special needs to be done, periodic is already assumed.
You should, however, take care that the last signal is the one before return to origin, not the return to origin itself. For example if you were sampling a function at each degree you would not sample at 0:360 (361 samples) you would sample at 0:359.

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by