Get both values and indices
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Md. Al-Imran Abir
am 3 Dez. 2022
Beantwortet: Dyuman Joshi
am 3 Dez. 2022
I am trying to get the indices and values from a vector based on a condition. I used find for that but the values it returning are logical values. How can I get actual values? An example is:
X = [4; 5; 1; 0; -7; 3; 0; 1; -4];
[row, ~, val] = find(X>0 & X<6)
I want val to have 4 5 1 3 1
0 Kommentare
Akzeptierte Antwort
Dyuman Joshi
am 3 Dez. 2022
X = [4; 5; 1; 0; -7; 3; 0; 1; -4];
row = find(X>0 & X<6)
val = X(row)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB 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!