How to count the number of points above and below a line
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
BENJAMIN BUCHDA
am 15 Feb. 2021
Beantwortet: Adam Danz
am 15 Feb. 2021
I need to write a function that takes x and y coordinates in a matrix and sums if they are above and on a straight line or below the line in different cells [above, below]. I have been provided the slope (m), and the intercept (b), and the (x,y) coordinates. I have really no idea where to start with this function so I was hoping someone better at matlab might have an idea how I should approach this function. Greatly appreciate it.
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 15 Feb. 2021
Let's say x stores all of the x-values of your coordinates. Compute the y-value on the line for each x-value.
yLine = m.*x + b;
If yLine is less than the original y coordinates, then the y coordinates are above or on the line.
isAboveOrOnLine = y >= yLine;
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!