Filter löschen
Filter löschen

Number of rows for given y

1 Ansicht (letzte 30 Tage)
Christopher Schoß
Christopher Schoß am 7 Mai 2022
Kommentiert: Voss am 8 Mai 2022
Hey,
i have loaded a .mat file in my workspace which contains 9x2 double.
First column represents x-values and second column y-vaules.
I have a specific y-values and want to find the number of rows with that y-value.
How can I calculate that?
Thank you!

Akzeptierte Antwort

Voss
Voss am 7 Mai 2022
M = randi(10,9,2) % random 9-by-2 matrix of integers between 1 and 10
M = 9×2
6 6 7 10 3 6 4 5 1 3 10 9 8 4 10 5 4 7
y = 6; % y value to find in the second column of M
nnz(M(:,2) == y) % number of times y appears in the second column of M
ans = 2
  3 Kommentare
Christopher Schoß
Christopher Schoß am 8 Mai 2022
Thank you!! Appreciate your help!
Voss
Voss am 8 Mai 2022
You're welcome!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by