comparing relevant elemnts of two matrix
Mostrar comentarios más antiguos
Hi all,
I have two matrics like below:
a=[9 7 NaN; 6 3 8; 15 NaN 5; NaN 4 2];
b= [10,14,NaN;10,10,13;10,NaN,10;NaN,10,10;] ;
I want to see if each element of "a" is less than or equal to its corresponding element in "b"?
how can I write this program .
Thanks in advance.
1 comentario
Muruganandham Subramanian
el 30 de Nov. de 2012
Can you mention the range?
Respuesta aceptada
Más respuestas (3)
Harshit
el 30 de Nov. de 2012
0 votos
size((A-B)>0)
Vishal Rane
el 30 de Nov. de 2012
Editada: Vishal Rane
el 30 de Nov. de 2012
By 'little-equal' I assume you mean 'less than or equal'.
Use
a <= b
assuming a,b are of same dimensions.
Wayne King
el 30 de Nov. de 2012
Editada: Wayne King
el 30 de Nov. de 2012
I'll assume that " littel-equal " means "less than or equal to"
a=[9 7 NaN; 6 3 8; 15 NaN 5; NaN 4 2];
b= [10,14,NaN;10,10,13;10,NaN,10;NaN,10,10;] ;
indices = find(a<=b);
a(indices)
The above gives the elements of a that are less than or equal to the corresponding element of b.
or
C = a<=b;
The matrix C has a 1 where the element of a is less than or equal to the element of b and a 0 otherwise
1 comentario
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!