How to add a line to the scatter?

조회 수: 20 (최근 30일)
Ilkin Abdullayev
Ilkin Abdullayev 2020년 4월 30일
댓글: Ameer Hamza 2020년 4월 30일
Hello everybody,
I have a problem to find a code which plot the line on my scatter plot. I have upload a pictures of scatter and the example line which I have drawn manualy.
If someone can help, I would be glad.
Thank you
  댓글 수: 6
Ameer Hamza
Ameer Hamza 2020년 4월 30일
yes, You can attach that as a .mat file.
Ilkin Abdullayev
Ilkin Abdullayev 2020년 4월 30일
Here is the some part of the data.
x axis is distance, y is load. The result will not be the same as in the pictures that I upload because it was a data for different date.

댓글을 달려면 로그인하십시오.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 4월 30일
The data you shared is distributed vertically, so I estimated a vertical line using lsqcurvefit. You can use a similar method if you know an approximate equation that fits your model.
load('mathwork.mat');
x = @(p, y) p(1)*y+p(2);
p = lsqcurvefit(x, rand(1,2), data.Load, data.Distance);
scatter(data.Distance, data.Load)
hold on;
plot(x(p, data.Load), data.Load, 'LineWidth', 2);
  댓글 수: 4
Ilkin Abdullayev
Ilkin Abdullayev 2020년 4월 30일
with curve fitting I gained the result. Thank you very much. I really appreciate.
Ameer Hamza
Ameer Hamza 2020년 4월 30일
I am glad to be of help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by