I have two matrices and I would like to create a matrix containing the above threshold value of each element of both matrices
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Marleen van Dijk
el 15 de Jun. de 2020
Respondida: Matt J
el 15 de Jun. de 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 comentarios
Respuesta aceptada
Más respuestas (1)
Matt J
el 15 de Jun. de 2020
Another way,
result=matrix2;
idx=(matrix2<threshold);
result(idx)=matrix1(idx);
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!