MATLAB Answers

I have two matrices and I would like to create a matrix containing the above threshold value of each element of both matrices

3 views (last 30 days)
Marleen van Dijk
Marleen van Dijk on 15 Jun 2020
Answered: Matt J on 15 Jun 2020
I have two matrices of the same size and for each element I would like to do the following:
if the value of the element in matrix2 is above the threshold, keep the value
else assign the value of matrix1 to this element.
Is this possible without for loops?

  0 Comments

Sign in to comment.

Accepted Answer

Matt J
Matt J on 15 Jun 2020
Edited: Matt J on 15 Jun 2020
Is this possible without for loops?
Yes. One way is as follows:
mask=(matrix2>=threshold);
result = matrix2.*mask + matrix1.*(~mask);

  0 Comments

Sign in to comment.

More Answers (1)

Tags


Translated by