Clear Filters
Clear Filters

Finding the 95% fit on an exponential graph

2 views (last 30 days)
I'm trying to find the 95% fit from an exponential curve I'm running. The exponential curve is fit, but I would like to find the coefficient for the dotted line (95% prediction bound). Is there a way to do this from the cftool I am using? Or am I better going another way entirely?

Answers (1)

Jakob B. Nielsen
Jakob B. Nielsen on 1 Jun 2021
There really should be a clever way to extract that info! I've looked at the cftool and I can't find an easy way. There is a rather involved way, though... Hit file -> generate code. Then run said code, you will get a figure and a handle named h. (Dont close the figure!)
In the command window, you can then inspect h. It will come up as a line array probably 3x1 in your case. This means h(3) is your prediction bound handle. You can then go and get h(3).XData and h(3).YData and you can put this back into the cftool and fit them, and this is your prediction bound expression.
If anybody has a more smooth way of doing this - up with it! :p
  2 Comments
Taylor Thomson
Taylor Thomson on 3 Jun 2021
Thank you! I'm new to this so I have another question.
I managed to extract the h(3) data, which is now in the arrays 'xd' and 'yd' respectfully. As this data is the upper bounf of an exponential fit to data already, putting it back into cftool would be fitting a curve to a curve, right?
Is there a way that I can find the exponential coefficient of the h(3) data using the arrays?
Photo is of h(3) being put back into cftool with an exponential fit to it
Jakob B. Nielsen
Jakob B. Nielsen on 3 Jun 2021
Hi Taylor,
Yeah you are correct, it is fitting a curve to a curve. But I couldn't see any other clever way of extracting the 95% prediction bound, and since you fit a curve to a curve, the expression you get out should be your 95% prediction bound expression.
One issue: your xd,yd fit looks like a straight line fit, even though the shape of the data is very obviously exponential in nature. An exponential decay tapers off approaching 0 as x goes to inf, and since this is data representing an upper bound you have data hitting what looks like 5,4 ish at x -> inf. You should try to subtract 5,4 (or whatever the correct value is, you can tell much more easily from the data than I can :) from the yd array and fit again - then add 5,4 to the finished full function.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!