point that are under line equation
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mili Kian
le 20 Avr 2020
Réponse apportée : Image Analyst
le 21 Avr 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
0 commentaires
Réponse acceptée
Michael Soskind
le 20 Avr 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
Plus de réponses (1)
Image Analyst
le 21 Avr 2020
I just answered this in your duplicate question: https://www.mathworks.com/matlabcentral/answers/518908-i-have-number-of-points-that-have-x-y-then-i-define-a-line-and-i-want-to-realize-which-points-are#comment_832507
0 commentaires
Voir également
Catégories
En savoir plus sur Eigenvalues dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!