for loop and indexing a matrix help
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Trying to make a function that if i input a matrix(x) and its conditions(cond), (x,cond)- it will resutun the index(row numders) that meet the conditions, as a vector. Any good examples of how this can be executed. Or if matlab has any helpful docs that can help?
0 comentarios
Respuestas (1)
KSSV
el 23 de Abr. de 2020
A = rand(5) ;
idx = A>0.7 ; % indices greater than 0.7
find(idx)
A(idx)
idx = A<0.5 ; % indices less than 0.5
find(idx)
A(idx)
idx = A>0.3 & A<0.7 ; % indices greater than 0.3 and less than 0.7
find(idx)
A(idx)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!