Curve fitting in frequency domain

조회 수: 3 (최근 30일)
Kirill Chukhlantsev
Kirill Chukhlantsev 2019년 2월 15일
댓글: dpb 2019년 2월 16일
Hi everybody, was working on a polyfit for a magnitude response of a signal, I have peaks around 21 and 109 Hz, so I wish a polyfit around those frequencies. What I've done so far:
AMPLITUDE = fft(amplitude);
first_peak = 20:1:22; %poorly trying here to define the X-axis around mentioned points of 21 and 109 Hz
second_peak = 108:1:110;
amp_to_fit1 = abs(AMPLITUDE(20:22)); %take values at those points
amp_to_fit2 = abs(AMPLITUDE(108:1:110));
amp_to_fit1 = amp_to_fit1.'; %transpose
amp_to_fit2 = amp_to_fit2.';
fitted_peak1 = polyfit(amp_to_fit1, first_peak, 2); %get the fitting coefficients
fitted_peak2 = polyfit(amp_to_fit2, second_peak, 2);
n = 0;
fitting_curve1 = fitted_peak1(1)*20*20+fitted_peak1(2)*20+fitted_peak1(3) %i know this is ugly, but I am quite new to matlab :D
fitting_curve2 = fitted_peak2(1)*108*108+fitted_peak2(2)*108+fitted_peak1(3)
for n = 21:1:22
fitting_curve1 = [fitting_curve1, fitted_peak1(1)*n*n+fitted_peak1(2)*n+fitted_peak1(3)];
n = n+1;
end
for n = 109:1:110;
fitting_curve2 = [fitting_curve2, fitted_peak2(1)*n*n+fitted_peak2(2)*n+fitted_peak2(3)];
n = n+1;
end
So, in the above code I've tried to build an array fitting_curve1 (and 2), having 3 points at 3 frequencies. (I will add more points later). However, values of the fit are far from what I expected. I anticipate that the issue is in my values of X-axis (how I define first_peak and second_peak variables), I have also the vector with time information from the initial signal.
Still finding my way around fft, so can not find the correct solution so far. Would appreciate some advice. Thanks
  댓글 수: 1
dpb
dpb 2019년 2월 16일
Need more background on what you're actually trying to do here...but a quadratic through three points will go through those three points exactly so there's really no point in doing such. Although, of course, depending on the particular points, there's no guarantee the intermediate points between the fitted points will be part of a parabola of the expected shape/direction.
The correct solution probably starts with a better definition of the problem trying to be solved...

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by