how can i get mean frequency in special rang?

1 view (last 30 days)
NGR MNFD
NGR MNFD on 2 May 2022
Answered: Jonas on 2 May 2022
I want to get mean ferequncy in rang f = (0.002 0.55) just this . from this code matlab but i get this eror(Array indices must be positive integers or logical values.)
I do not know how to perform my work to solve this problem
my code matlab is:
for i = 1:1
data1 = load(strcat(strcat('park',num2str(i)),'.ts'));
fft1 = fft(data1);
M2 = abs(fft1.^2./length(data1));
f = (0.8167/2)*(0:(length(data1)-1))/length(data1);
figure,hold on;plot(f,M2(:,13),'r','linewidth',1.5);xlim([0.002 0.55]);
% % extract freq feature
% N = mean(M2(0.002 0.55));
end

Answers (1)

Jonas
Jonas on 2 May 2022
use
mean(M2(f>0.002 & f<0.55))

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!