point that are under line equation

4 ビュー (過去 30 日間)
Mili Kian
Mili Kian 2020 年 4 月 20 日
回答済み: Image Analyst 2020 年 4 月 21 日
i have multi sentence equation and some point like this:
0<x<5 y=6
5<x<12 y=3x+6
12<x<15 y=-3x+7
15<x<20 y=6
and my points are(x,Y)
1 1
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
3 1
3 3
3 5
3 7
3 9
3 11
3 13
3 15
3 17
5 1
5 3
5 5
5 7
5 9
5 11
5 13
5 15
5 17
7 1
7 3
7 5
7 7
7 9
7 11
7 13
7 15
7 17
9 1
9 3
9 5
9 7
9 9
9 11
9 13
9 15
9 17
11 1
11 3
11 5
11 7
11 9
11 11
11 13
11 15
11 17
13 1
13 3
13 5
13 7
13 9
13 11
13 13
13 15
13 17
15 1
15 3
15 5
15 7
15 9
15 11
15 13
15 15
15 17
17 1
17 3
17 5
17 7
17 9
17 11
17 13
17 15
17 17
how can i find which point are under the equation

採用された回答

Michael Soskind
Michael Soskind 2020 年 4 月 20 日
Hi Mili,
There are a few ways to go about this, I think the most obvious is the one I outline below:
% Redefining columns as x and y for clarity
x = C(:,1);
y = C(:,2);
% Conditions stated in question
cond_1 = x > 0 & x < 5 & y < 6;
cond_2 = x > 5 & x < 12 & y < 3*x + 6;
cond_3 = x > 12 & x < 15 & y < -3*x + 7;
cond_4 = x > 15 & x < 20 & y < 6;
% Selecting the points matching the conditions
points_below = C(cond_1 | cond_2 | cond_3 | cond_4, 1:2)
The method above assumes the array is called C. I redefine the columns into variables. I then use conditional statements that select for points matching the conditions above. NOTE: You may want to review the conditions you have in place, as they seem a bit strange to me, and maybe not what you are intending for.
However, the above should provide you with the final set of points as shown in the array points_below. Conditional statements are very powerful in Matlab.
Best,
Michael
  1 件のコメント
Mili Kian
Mili Kian 2020 年 4 月 21 日
thank you
yes,as you said 'Conditional statements are very powerful in Matlab.'
best regard

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 4 月 21 日

カテゴリ

Help Center および File ExchangeEigenvalues についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by