MATLAB: Fit a curve with smallest distance in y AND x direction to data points

curve fittingmaeregressionrmse

I have two sets of measurements x and y that seem to be correlated when plotting them against each other (below a small subsample of my data). I would like to fit a curve (linear, exponential, polynomial ..) through my data, such that it minimizes the distance of my points to the line (in an absolute or mean square way), but not only minimizing the distance on the y axis, but the closest distance in the x,y plane (euclidean distance). Is there a function/way to do that? As I understand it, most curve fitting functions in MATLAB fit the according to the rmse in y-direction only.
x =[1.3049 1.4137 0.2165 0.6538 0.6135 1.0655]
y =[4.0280 4.0865 50.1873 11.8024 7.9184 5.5866]

Best Answer

It sounds like you want "orthogonal linear regression".