Limiting range of a matrix
Show older comments
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)
Accepted Answer
More Answers (1)
A = [1 2 3 4 5 6 7 8];
A(A<3) = 3;
A(A>6) = 6;
A
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
