FInding the breakpoint of a frequency spectra and its associated error

2 views (last 30 days)
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.

Accepted Answer

Mathieu NOE
Mathieu NOE on 1 Feb 2021
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

More Answers (1)

Mahith Madhana Kumar
Mahith Madhana Kumar on 1 Feb 2021
Thank you Mathieu. That was helfpul.
I was wondering what the error associated with the a_sol value is (the first breakpoint). How should I find the error associated with a_sol?
Thanks.
  2 Comments
Mathieu NOE
Mathieu NOE on 1 Feb 2021
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

Sign in to comment.

Categories

Find more on Predictive Maintenance Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!