This routine calculates the median squared error of a linear function, and can be used with fminsearch as a robust linear regression (see help LinearMedianSquaredError).
It should be very easy to extend the example code to handle nonlinear functions and to minimize other error functions (least absolute error, for instance).
Will Dwinnell (2022). Linear Median Squared Error (https://www.mathworks.com/matlabcentral/fileexchange/27204-linear-median-squared-error), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!