Derive equation from dataset
Mostra commenti meno recenti
Hello!
I have the following four sets of data:
x11=[0 8 32 35 38 46 50 62];
y11=[288 288 224 183 155 29 23 0];
x12=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 26 35 36 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 71];
y12=[1830 1830 1830 1779 1779 1779 1779 1481 1481 1225 1225 1128 1128 995 995 707 707 682 682 661 661 607 515 511 344 344 344 339 339 339 332 332 332 319 319 319 305 305 305 261 261 261 249];
x21=[0 12 18 20 22 23 24 26 31 32 35 37 38 39 48 50 54 57];
y21=[715 715 670 643 639 616 612 581 521 466 421 369 318 326 109 55 7 0];
x22=[0 5 6 9 16 21 22 23 24 35 37 38 40 44 48 58 72 73 77];
y22=[6833 6833 6776 5704 2497 1893 1779 1706 1741 1444 1335 1256 1217 967 947 812 649 593 551];
All x-y pairs have quite the similar shape, with the curve decaying rapidly in the first half and then slowly in the second one.
The goal is to interpolate each x-y pair to derive an equation that will represent the phenomenon.
I tried interp1 and lsqcurvefit but they don't give good enough results. Could someone suggest an alternative way to interpolate these data?
Thank you!
3 Commenti
Adam Danz
il 26 Feb 2019
"I tried interp1 and lsqcurvefit but they don't give good enough results"
Interpolation won't give you the underlying equation. lsqcurvefit() (or lsqnonlin) works pretty well but you've got to supply it with a function and the results depend heavily on the boundaries and initial starting points specified by the user. So, are you trying to find what type of equation would produce these data (without noise) or are you trying to find the parameters of a known equation that results in a best fit of your data?
If you're trying to do that latter, I'd recommend using lsqnonlin() directly (which is what lsqcurvefit is using) and make sure you're supplying a reasonable function, bounds, and starting points.
Alberto Basaglia
il 26 Feb 2019
Adam Danz
il 26 Feb 2019
I agree with the answer below. The curve fitting toolbox is a good start.
Risposta accettata
Più risposte (1)
Walter Roberson
il 26 Feb 2019
0 voti
There are an infinite number of equation that fit your data perfectly in theory , even without allowing for the possibility of noise or of imperfect recording of coefficients .
The number of equation you can derive from the data using no more than 2^48 bytes of memory (limit of x64 architecture in all known implementation ) representing your coefficients as IEEE double precision (64 bits) is a bit more limited but probably still over 2^40
With an infinite number of derived equations, the probability that any one of them is the "correct" equation is 1/infinity which is defined as 0.
Therefore you cannot do anything useful in fitting your data unless you can restrict your equation to being one of a finite number of forms, after which you can do parameter fitting for each of the possible forms and make a decision as to which fits best.
Categorie
Scopri di più su Get Started with Curve Fitting Toolbox in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!