# How do I fit along the curve.

23 views (last 30 days)
TAEYUN KIM on 13 Apr 2021 at 8:29
Answered: John D'Errico on 13 Apr 2021 at 11:04
Hello everyone. I am looking for a fitting method as shown in the picture below.
Typically, curve fiiting is completed with minimized error.
f = mean((Original_Signal-Fitted_Signal).^2) is objective funtion for curve fitting.
However, I want to do a fitting that wraps around the outline of the curve. In other words, I want to automatically find the slope and the point (or time) of the two straight lines surrounding the outline.
I've tried using patternsearch and fminsearch to do this, but all of them found only the slopes and fields with minimal error.
Please tell me how to do this, or if there is a matlab built-in function.

John D'Errico on 13 Apr 2021 at 11:04
Why would there be code written to do something completely strange? Well, perhaps I should not call it strange, but your idea of fitting a curve in this way is not something I have ever seen requested.
Before you solve a problem on a computer, you need to understand the mathematics of what you are asking. I believe what you want to know are the pair of lines the curve approaches, in an asymptotic sense, but this is just my guess. Given those two asymptotes, if you wanted, you could find their point of intersection, and then construct the segmented curve you have drawn. So this is not really a curve fitting problem directly, but a problem of finding an asymptote, rather a pair of asymptotes.
And of course, without any data, it becomes more difficult to help you. Some questions arise, as to how noisy is your data, and if it will always take a similar shape. How much data will you have?
So it would be greatly helpful to allow us to help you, if you would post a .mat fiile, attached to a comment or to your original question that contains a sample of your data. While I could with some minor effort, construct some hyperbolic data of the form you show, it is far better to look at the real data.