Curve Fitting for experimental data

1 view (last 30 days)
nony lew
nony lew on 12 Apr 2018
Edited: dpb on 14 Apr 2018
I have some experimental data:
x = [6.46:0.02:9.74]
y = [14200 14195 14155 14147 14145 14139 14107 14102 14101 14096 14067 14063 14057 14057 ...
14019 14016 14013 14006 14001 13994 13984 13970 13964 13948 13943 13935 13921 13903 ...
13902 13879 13867 13854 13836 13826 13813 13785 13775 13750 13733 13711 13694 13671 ...
13649 13636 13612 13604 13581 13563 13542 13529 13505 13495 13473 13464 13450 13433 ...
13426 13421 13418 13401 13387 13382 13380 13378 13377 13371 13373 13357 13342 13337 ...
13334 13334 13333 13331 13322 13295 13291 13289 13252 13246 13243 13202 13168 13155 ...
13145 13110 13104 13066 13062 13023 13018 12979 12971 12933 12925 12896 12884 12867 ...
12842 12836 12828 12796 12788 12784 12752 12754 12747 12745 12743 12742 12723 12710 ...
12710 12708 12705 12707 12706 12706 12705 12704 12703 12699 12698 12675 12662 12660 ...
12658 12649 12619 12616 12580 12570 12563 12527 12521 12482 12476 12438 12429 12394 ...
12386 12346 12331 12302 12297 12265 12248 12243 12213 12205 12199 12168 12164 12160 ...
12127 12121 12142 12076 12122 12126 12123 12130]
and I want to fit them with a function
y=a1*x+a2+sin(a3*x+a4)
I mention that I do not know anything about coefficients (a1,a2,a3,a4), I want to find out those coefficients value.
  8 Comments
dpb
dpb on 13 Apr 2018
Edited: dpb on 14 Apr 2018
Indeed; at least being able to provide a start point would help albeit with a simplified user interface and inexperienced users whether they would stumble upon the importance without serious prompting is problematical I'd guess...but, definitely need some way to avoid issues like with the OPs data.
I wasn't at all surprised when trying with the original data that as a sine of roughly 100 pk-pk amplitude riding on a baseline of 10E4; just the linear term alone is an R-square > 0.93 so there's very little residual left to account for from the total albeit it's really what's of interest.
I did have (I thought reasonable) expectations when trying with the residual as the y variable but nothing I could do by trying to fudge terms inside the model helped a bit with the custom model; however it gets and whatever it uses for initial values were just too far out in left field.
dpb
dpb on 13 Apr 2018
Well, I hadn't known what it did for starting guesses; with your comment, John, I did
y = 60*(1+a)*sin(6*(1+b)*x+(c-5))
as the custom model after fitting the sine model with the specialized model and using approximate values for the coefficients thus found. This way was able to find
a=0.04007
b=0.05077
c=0.1772
R-sq = 0.838 RMSE 19.68 for the residual portion. That compares almost identically then with the 'Sum of Sines' model solution. "Going round Robin Hood's barn" comes to mind.............
Hmmm...that makes for interesting question...nope, using
z=zscore(r);
as the response variable isn't enough of a klew it still failed with the straight model as 'Custom Equation'. Disappointing, that... :(

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!