How to add a line to the scatter?
30 ビュー (過去 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
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!