How can I plot an arc that can connect three-point in the x,y plane, the points are 2*1 matrix. Actually, I look to create a function so I can use it many times.

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 3 月 13 日

0 投票

Note that this code considers the points to be unordered, and connects them in x order.
Also, this code is not designed to be able to handle vertical (or near vertical) connections. For example connect3([1;1], [1;3], [2,2]) will give it problems.
connect3(randn(2,1), randn(2,1), randn(2,1));
connect3(rand(2,1)*2, rand(2,1)*2, rand(2,1)*2);
function connect3(A, B, C)
x = [A(1); B(1); C(1)];
y = [A(2); B(2); C(2)];
[x, idx] = sort(x);
y = y(idx);
p = polyfit(x, y, 2);
xp = linspace(x(1),x(3),20);
yp = polyval(p, xp);
line(xp, yp);
end

5 件のコメント

Abdulaziz Alnaghmoush
Abdulaziz Alnaghmoush 2021 年 3 月 13 日
Thank you so much
darova
darova 2021 年 3 月 13 日
This is parabola, not an arc
Walter Roberson
Walter Roberson 2021 年 3 月 13 日
Oh? How is an arc defined? Is a parabola not a connected subset of a differentiateable function?
https://en.m.wikipedia.org/wiki/Curve#Differentiable_arc
darova
darova 2021 年 3 月 13 日
I thought arc is a part of circle
Walter Roberson
Walter Roberson 2021 年 3 月 13 日
Nope, any curve that you can differentiate.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

タグ

質問済み:

2021 年 3 月 13 日

コメント済み:

2021 年 3 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by