FInding the breakpoint of a frequency spectra and its associated error
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi all,
I was wondering whether somebody could help me in finding the first breakpoint of a frequency spectra and its associated error. The spectra is as shown in the attached figure (spectrum.jpg). The spectrum should be fitted as shown in spectrum_fitted.jpg inorder to find the first breakpoint (labelled as A) so as to get the corresponding frequency which is about 1.2Hz (in figure spectrum_fitted.jpg). The fit might not be accurate and hence there would be an associated error in the value obtained for the frequency at A. So I would need both the value for frequency at A( first breakpoint) as well as its associated error. Wondering if that is possible.
The data used to get the frequency plot has been attached as data.mat
Thank you.
댓글 수: 0
채택된 답변
Mathieu NOE
2021년 2월 1일
hello
I combinde this
and fminsearch to create that code - seems to work finding the optimal values for break points
% load x and y data
load('data.mat');
xdata = xdata(:);
ydata = ydata(:);
% Init of fminsearch
a = max(xdata)/4;
b = max(xdata)*3/4;
global xdata ydata
x0 = [a,b];
x = fminsearch(@obj_fun, x0);
a_sol = x(1);
b_sol = x(2);
XI = [min(xdata),a_sol,b_sol,max(xdata)]; % vector of 1-D look-up table "x" points
YI = lsq_lut_piecewise( xdata, ydata, XI ); % obtain vector of 1-D look-up table "y" points
% plot fit
plot(xdata,ydata,'.',XI,YI,'+-')
legend('experimental data (x,y(x))','LUT points (XI,YI)')
title('Piecewise 1-D look-up table least square estimation')
function err = obj_fun(x)
global xdata ydata
XI = [min(xdata),x(1),x(2),max(xdata)]; % vector of 1-D look-up table "x" points
YI = lsq_lut_piecewise( xdata, ydata, XI ); % obtain vector of 1-D look-up table "y" points
Yint = interp1(XI,YI,xdata);
err = sum((Yint-ydata).^2);
end
댓글 수: 0
추가 답변 (1개)
Mahith Madhana Kumar
2021년 2월 1일
댓글 수: 2
Mathieu NOE
2021년 2월 1일
hello again
well, there is no "reference" value for a , so I cannot say the error is the norm of a_ref-a_sol , because a_ref cannot be defined (or ?)
the only error we can define is : err = sum((Yint-ydata).^2); used in the function
but that is not specific to a but to the entire fit model
참고 항목
카테고리
Help Center 및 File Exchange에서 Predictive Maintenance Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!