Line of best fit not plotting correctly

조회 수: 25 (최근 30일)
Em
Em 2022년 2월 28일
답변: William Rose 2022년 2월 28일
Hi,
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?
figure
scatter(E5half41,logI5_41,5)
hold on
y=-0.1172.*E5half41+3.954;
plot(y,E5half41)
cheers!

채택된 답변

Star Strider
Star Strider 2022년 2월 28일
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.
.

추가 답변 (1개)

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

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by