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.

 채택된 답변

Joseph Cheng
Joseph Cheng 2014년 4월 9일
편집: Joseph Cheng 2014년 4월 9일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2014년 4월 9일

편집:

2014년 4월 9일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by