Limiting range of a matrix
Afficher commentaires plus anciens
I have matrix A = [1 2 3 4 5 6 7 8];
I try to limit the matrix to numbers greater than 3 and less than 6 how do I do it ?
I use this line but it assigns numbers less then 3 to 3 and numbers greater then six to six. Instead i want to eliminate those numbers in matrix which dont belong in this range.
max(min(A,3),6)
Réponse acceptée
Plus de réponses (1)
A = [1 2 3 4 5 6 7 8];
A(A<3) = 3;
A(A>6) = 6;
A
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

