Getting a maximum from a fitted curve (smoothing spline)?

6 ビュー (過去 30 日間)
Jacques Mclean
Jacques Mclean 2019 年 3 月 16 日
コメント済み: John D'Errico 2019 年 3 月 16 日
Context: vibration experiments, plotting frequency vs displacement
What I have: data for freqency (x) and displacement (y). Plotted they form roughly a -x^2 shape. I used the curve fitting tool, with smooth spline selected to interpolate my data. The code returned was as follows:
% Fit
[xData1, yData1] = prepareCurveData( Frequency_UD, Displacement_UD );
% Set up fittype and options.
ft = fittype( 'smoothingspline' );
% Fit model to data.
[fitresult{1}, gof(1)] = fit( xData1, yData1, ft );
%plot
plot( fitresult{1},'c', xData1, yData1, 'k.');
What I want: I want to determine the resonant frequency (the point where displacement is greatest), so basically the peak of my graph. Obviously I can calculate it or visually locate it but thats not the point of the question.
For further clarity here is a picture of the graph I am working on
Screenshot 2019-03-16 at 01.20.27.png

採用された回答

John D'Errico
John D'Errico 2019 年 3 月 16 日
Where does the problem lie? Are you surprised that the spline does not pass through the maximum data point? So are you just asking how to locate the maximum point, or are you worried that the smoothing spline seems to have missed that max?
Any smoothing tool will tend to reduce the peaks, increase the valleys. This is especially true of sharp peaks. Why? Because that is a location where the function is most inconsistent with the rest of the curve. So unless you have a nice, smooth, well-behaved maximum, then the smooth will tend to reduce it, to draw it down. Because it looks like it might be noise.
There are bumps in your data, clearly noise. So why should the smoothing tool not be willing to disbelieve just a little bit of that extreme point?
If you NEED to find the maximum, AND you believe that that peak is what you are looking for, then you NEED to use an interpolating spline, NOT a smoothing spline.
Ok, perhaps your question is not why does the curve not pass smoothly through the peak. Perhaps you are just trying to find out how to locate that maximal value.
How do you find a minimal point on a curve? The simple answer is to just use fminbnd, at least in one dimension. Or you could as easily use fminsearch. It will work fine here, though not quite as efficiently. But you want to find a maximum. The classic answer in optimization, as to how to find a max, is just find a minimum of the negative of your function. Multiply it by -1. Then use a minimization tool. Either fminbnd or fminsearch will suffice. (You could also use my SLM toolbox, which does have a tool in there that will locate the maximum or minimum point on a spline. But you don't need that here, and there is no reason to go that far.)
  4 件のコメント
Jacques Mclean
Jacques Mclean 2019 年 3 月 16 日
this was very helpful, thank you so much!
(also love your toolbox :) )
John D'Errico
John D'Errico 2019 年 3 月 16 日
:)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by