Find flattest line from matrix of vectors plotted against x values

3 views (last 30 days)
Hi there,
I have a matrix of y-axis coordinates, which I'm plotting against a constant set of x-axis coordinates. I want to determine which of these plotted lines has the flattest line overall, i.e. the line that overall shows the least variation with the x-coordinates.
Can anyone recommend how to do this?
Thanks!

Accepted Answer

Jeff Miller
Jeff Miller on 6 Feb 2019
If you want to find the y-matrix row with the least variation, you could simply find the row with the small std, range, or mean absolute deviation of y values. If you want the flattest line in the sense of minimum abs(slope) versus x, you will probably have to fit a line for each row.
  1 Comment
John D'Errico
John D'Errico on 7 Feb 2019
To me the issue seems to me the definition of flatness.
For example, you might have a perfectly fitting line, with a slope of 10, but no deviation from that line. Is that "flat"?
Or, how about a parabolic shape, but one that will have a resulting slope of zero, when you fit the line to it. I the slope is zero, is that "flat"?
Or, what about a noisy set of points, but one that has again, a slope that is perfectly zero. Again, is that "flat"?
So what is needed is the definition of what "flat" means here.
Note that the final computation of a set of least squares fits can actually be achieved with merely a dot product, so a matrix*vector product, to then compute the slopes of every line at once.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!