Hello,
In my matrix c, how do I find the first time the value 700 appears searching one row at a time before moving onto the next?
Thank you.

Réponses (2)

Jan
Jan le 26 Avr 2021
Modifié(e) : Jan le 26 Avr 2021
c = [0, 0, 700; 1, 2, 3; 4, 700, 1];
d = c.';
[col, row] = find(d == 700, 1)
i2 = 3
i1 = 1
Here the column index is replied at first, because the input was transposed.
I am not certain what you want.
Try this —
c = randi([650 750], 25);
[cr,cc] = find(c==700)
cr = 12×1
18 3 13 3 19 22 24 6 12 19
cc = 12×1
2 4 7 9 12 14 17 19 21 21
[RowMin,Idx] = min(cr)
RowMin = 3
Idx = 2
First700 = [RowMin, cc(Idx)]
First700 = 1×2
3 4
.

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by