Hello, I'm having trouble figuring out how to replace values in a matrix that fall between two values.
For example, lets say i have matrix, and i want to replace all values that fall between 20 and 50 with -3 instead, how would I go about doing that?

 채택된 답변

Adam Danz
Adam Danz 2021년 2월 6일

1 개 추천

Use basic Matlab indexing.
M(M>20 & M<50) = -3;

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2021년 2월 6일

댓글:

2021년 2월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by