Replacing values in a matrix

조회 수: 13 (최근 30일)
Naoufel Farid
Naoufel Farid 2021년 2월 6일
댓글: Naoufel Farid 2021년 2월 6일
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일
Use basic Matlab indexing.
M(M>20 & M<50) = -3;
  댓글 수: 1
Naoufel Farid
Naoufel Farid 2021년 2월 6일
Thank you this worked great!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by