How can I substitute values in a matrix if they equal a certain value?
4 次查看(过去 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 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!