Changing some elements of a matrix.
1 view (last 30 days)
Show older comments
I have a matrix, which looks like 150 110 95 110 200 and so on. Now, i want to replace all elements up 95 (or less than 100) to 100, so that my new matrix should look like 100 100 100 110 200 Can anyone suggest me a good way to do this? Thanks.
0 Comments
Accepted Answer
Joseph Cheng
on 9 Apr 2014
Edited: Joseph Cheng
on 9 Apr 2014
I do not understand what you want to replace but if you know the inequality statement (A<B) you can do something like this
MATRIX(MATRIX<100) = 100; which will set all elements within your matrix which is less than 100 to 100.
or if there are two inequalities to satisfy.
MATRIX(MATRIX<100 & MATRIX>95) = 100; Set all elements in MATRIX which are between 95 and 100 to 100.
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical 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!