loop for removing highest value until specific value is reached
Mostrar comentarios más antiguos
for exmaple,
for 10x10 matrix A
i want to make loop which removes highest element until sum of A is less than 20
and i want to know each removed element's position
i think 'while-loop' is needed
( I only know finding the first highest value using 'for-loop')

Respuesta aceptada
Más respuestas (1)
David Hill
el 18 de Jul. de 2022
[b,idx]=sort(A(:));
IDX=idx(cumsum(b)>=20);%linear index of each of the removed element's position
1 comentario
형준 이
el 19 de Jul. de 2022
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!