find values for the equation of a circle

2 ビュー (過去 30 日間)
Duncan
Duncan 2014 年 8 月 14 日
コメント済み: Duncan 2014 年 8 月 25 日
I have the equation of a circle:
(x - a)^2 + (y - b)^2 - r^2 = 0
a, b and r are known values but I would like to find the values of x and y from a predetermined coordinate matrix which satisfies the equation.
example: a = 2, b = 2, r = 2
A =
1 2
1 3
2 4
hence the last row in A(2,4) would satisfy the equation. i.e. x = 2, y = 4
this is what I've tried so far:
a = 2;
b = 2;
r = 2;
x = find(A(:,1);
y = find(A(:,2);
solve((x - a)^2 + (y - b)^2 - r^2 == 0)

採用された回答

Roger Stafford
Roger Stafford 2014 年 8 月 14 日
編集済み: Roger Stafford 2014 年 8 月 14 日
a = 2; b = 2; r = 2;
A = [1 2;1 3;2 4];
B = A((A(:,1)-a).^2+(A(:,2)-b).^2==r^2,:);
B contains the coordinate pairs, if any, that lie on the circle. Note that if you need this for values of a, b, and c which are not integers, it is best to allow a small tolerance for round-off errors rather than demanding exact equality in the equation.
  3 件のコメント
Roger Stafford
Roger Stafford 2014 年 8 月 14 日
That was an error. I have now corrected it. My apologies.
Duncan
Duncan 2014 年 8 月 25 日
I have another question related to this. Say:
A = 1 2
1 3
2 4
4 2
then the last two values would satisfy and hence display 2,4 and 4,2.
What I would like to know is how this code would change if i set limits. Say I want to display only the value that is within the limits of +/-1 of a & b.
i.e. it would only display 2,4

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics and Optimization についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by