# FInding the breakpoint of a frequency spectra and its associated error

13 views (last 30 days)
Mahith Madhana Kumar on 1 Feb 2021
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.

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
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

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 CommentsShowHide 1 older comment
Mahith Madhana Kumar on 1 Feb 2021
Thank you for the clarification, Mathieu

### Categories

Find more on Spectral Estimation 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!

Translated by