point that are under line equation

4 Ansichten (letzte 30 Tage)
Mili Kian
Mili Kian am 20 Apr. 2020
Beantwortet: Image Analyst am 21 Apr. 2020
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

Akzeptierte Antwort

Michael Soskind
Michael Soskind am 20 Apr. 2020
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 Kommentar
Mili Kian
Mili Kian am 21 Apr. 2020
thank you
yes,as you said 'Conditional statements are very powerful in Matlab.'
best regard

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 21 Apr. 2020

Kategorien

Mehr zu Eigenvalues finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by