For most of my data this code works fine, but I am having a very poor fit for the following section of data. Does anyone know what I did wrong?
x = [1.7125 5.0430 9.1750 15.4250 22.7550 30.3800 40.4500 52.4150 63.9400 74.5300 89.5500 105.3000 119.8000 135.9000 153.4500 167.5000 185.4000 205.9000 223.9000 244.5000 267.7000 290.8500 317.6000 341.9500 367.9000 399.1000 432.7500 461.8000 493.4500 521.5000 555.6000 588.4500 617.5500 654.2000 688.9000 729.6000 772.2000 820.5000 862.5000]';y = [3.7148 3.3178 2.7135 2.4753 2.2017 1.9689 1.6732 1.5649 0.6837 0.4081 0.3183 0.2845 -0.3022 -0.1981 -1.1470 -1.7174 -1.6783 -1.2277 -2.3289 -2.5576 -2.4626 -2.5281 -3.4626 -2.8697 -4.7081 -3.6971 -3.7245 -4.7752 -4.7768 -4.6965 -5.3429 -6.0585 -5.4439 -6.2222 -6.2646 -6.1612 -6.4458 -6.8387 -6.9563]';scatter(x,y,5,[0 0 0],'fill');hold onf = fit(x,y,'exp2');x2=linspace(min(x),max(x));y2=f(x2);plot(x2,y2,'color',[0 0 0],'linewidth',2);
Best Answer