How can I substitute values in a matrix if they equal a certain value?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have two matrices X1 and X2 (both have dimensions 512x512) I would like to write code to create a new matrix that has the element values from X1 in, unless the element equals 255- in which case I would like to use the element from the same coordinate from X2 instead.
I hope this makes sense! Thanks for your help :)
댓글 수: 0
채택된 답변
Mischa Kim
2014년 4월 16일
편집: Mischa Kim
2014년 4월 16일
Claire, you could use something like
X3 = X1;
X3(X1==255) = X2(X1==255);
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!