필터 지우기
필터 지우기

single sided amplitude fourier spectrum

조회 수: 9 (최근 30일)
Muhsin
Muhsin 2017년 10월 12일
댓글: Star Strider 2017년 10월 18일
Hello all, I am new user that trying to learn coding. I have an acceleration-time history with a time-step of 0.01 sec. The total duration is 14 sec. I would like to get a single-sided fourier spectrum of it. Is there any packed code for it? Any kind of help is appreciated. The attached file contains the data. Thank you.
Muhsin

채택된 답변

Star Strider
Star Strider 2017년 10월 12일
편집: Star Strider 2017년 10월 12일
See the documentation for fft (link).
The Code
D = dlmread('Muhsin A00.txt', '\t', 1,0);
t = D(:,1); % Time (s)
a = D(:,2); % Acceleration (g)
L = length(t);
Ts = t(2)-t(1); % Sampling Interval (sec)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
FTa = fft(a)/L; % Fourier Transform (Scaled)
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
figure(1)
plot(Fv, abs(FTa(Iv))*2) % One-Sided Amplitude Plot
xlabel('Frequency (Hz)')
ylabel('Amplitude (g)')
grid
EDIT Changed ‘Ts’ calculation to accommodate ‘t(1)=0.01’ and ‘t(end)=0’.
  댓글 수: 19
Muhsin
Muhsin 2017년 10월 18일
How about smoothdata function. Wouldn't that work well? Thank you
Star Strider
Star Strider 2017년 10월 18일
The smoothdata function would likely work. (It was introduced in R2017a, and since I do not know what version you have, I did not suggest it.)
You would use it on the absolute value of your single-sided Fourier transformed data.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 10월 12일
Isn't that what pwelch() does? (Signal Processing Toolbox required for pwelch).
  댓글 수: 1
Image Analyst
Image Analyst 2017년 10월 12일
You might also like spectrogram() function.
Or the Signal Analyzer app on the Apps tab of the tool ribbon.

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by