Line of best fit not plotting correctly

9 views (last 30 days)
When I use the graph app to find a line of best fit to my data, everything seems to be working fine (see attached image).
But when I try to plot this line of best fit alongside the scatter data, the line is nowhere near. Does anyone know what might be going on?
hold on

Accepted Answer

Star Strider
Star Strider on 28 Feb 2022
Try this —
plot(E5half41, y)
The independent variable is the first argument.
I cannot run the code without the data, however that would appear to be an appropriate guess as to what the problem is.

More Answers (1)

William Rose
William Rose on 28 Feb 2022
@Em, X and Y are flipped, for the best fit line plot, compared to what they should be.

Community Treasure Hunt

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

Start Hunting!