Hi there,
I have this code and I would like to get the correct y-intercept (and gradient) for my slope. You can see from the image generated that this function gives me the wrong intercept value. I have tried switching lat and long and I still cannot get the correct value. Does anyone know how I can amend this so it works?
I would also like to measure the fir of my data- Please can someone help me with that?
Many thanks,
lat = [30.4056270000000;30.3991500000000;30.4000740000000;30.4046990000000;30.4102510000000;30.4093280000000;30.3889660000000;30.3982300000000;30.4074760000000;30.4195050000000;30.4139500000000;30.4120980000000;30.4083980000000;30.3936010000000;30.3926810000000];lon = [40.7602680000000;40.7609660000000;40.7616710000000;40.7623780000000;40.7623830000000;40.7602710000000;40.7644750000000;40.7574480000000;40.7616770000000;40.7609820000000;40.7637930000000;40.7651980000000;40.7637880000000;40.7595540000000;40.7560360000000];f=fit(lat, lon,'poly1')plot(f,lat,lon,'o')xlabel longitudeylabel latitude
The output of the function is:
f = Linear model Poly1: f(x) = p1*x + p2 Coefficients (with 95% confidence bounds):
p1 = 0.1116 (-0.04946, 0.2726) p2 = 37.37 (32.47, 42.27)
Best Answer