10-13-2014 09:41 AM
I have data that approximates to the following function:
f(x) = A; x<E
f(x) = Bx + C; E<=x<F
f(x) = D; x>F
I am trying to use the non-linear fit function and having issues with a singular matrix error. I feel I have approximated my parameters pretty well, and the plot of the best fit curve seems to line up pretty well, but it seems as though it is not iterating through my E and F approximations and just using what I give it. Could someone take a look at my code and offer me some additional guidance? The points that I particularly need are the "A" value and when f(x)=0 from the second function. If there is an easier way to find these values I'm all ears.
Thanks
Solved! Go to Solution.
10-13-2014 09:52 AM
You did not make the paramter estimates as default before saving, so all we have is an empty array.
What are your initial parameters?
10-13-2014 09:58 AM
Ooops, sorry.
A = 1
B = -2
C = 10
D = 0.01
E = 3.8
F = 4.2
I also realized soon after submitting that E & F could be dependent on A, B, & C, so I am trying again with that in mind.
10-13-2014 10:15 AM - edited 10-13-2014 10:16 AM
Yes, you only need four parameters.
(interpolate linearly between first and second x from first to second level).
See attached for a quick draft.
10-13-2014 10:23 AM
Thanks, that works much better. Given my data, it was going to be difficult to come up with a prediction for the slope and y-intercept, this works out much better as I know approximately what A should be, and where the x-intercept should be.
10-13-2014 10:31 AM
Of course you could paramterize it in many different ways, e.g. intercept, slope, x1, x2, so modify as needed.
Just define the linear equation and, inside the model, coerce the x-values to lie between x1 and x2.
10-13-2014 10:39 AM - edited 10-13-2014 10:40 AM
@altenbach wrote:
Of course you could paramterize it in many different ways, e.g. intercept, slope, x1, x2, so modify as needed.
Just define the linear equation and, inside the model, coerce the x-values to lie between x1 and x2.
Here's what I had in mind.
See how simple the model gets! 😄