Replacing values in a matrix

18 次查看(过去 30 天)
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;

更多回答(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