how to set limits of integration (for example: 0:inf) for a vector using trapz tool ?

4 ビュー (過去 30 日間)
mavi gul
mavi gul 2019 年 10 月 23 日
編集済み: Daniel M 2019 年 10 月 26 日
%defining a linear modulated signal
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sample time
L = 5000; % Length of signal
t = (0:L-1)*T; % Time vector
a=chirp(t,5,max(t),20,'linear');
f=fft(a);
F=(0:L-1)/Fs;
e=trapz(F,(abs(f).^2));
%finding the average frequency
x=trapz(F,F.*abs(f).^2);
AVG=x./e
Untitled.png

採用された回答

Daniel M
Daniel M 2019 年 10 月 23 日
編集済み: Daniel M 2019 年 10 月 26 日
Your vector of frequencies is not correct, because fft returns the negative frequencies first, followed by the positive frequencies. I suggest looking at the documentation for fft.
Otherwise, trapz will integrate over whatever values you provide it. If you want it to integrate over a certain interval, only pass those elements as inputs. You can also look into integral().
Correction: fft returns the frequencies in the following order: zeroth frequency, positive frequencies up to the Nyquist freq, followed by the negative frequencies in ascending order.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by