Borrar filtros
Borrar filtros

how to match different values of a matrix

1 visualización (últimos 30 días)
PRAVEEN GUPTA
PRAVEEN GUPTA el 28 de Ag. de 2019
Comentada: Guillaume el 28 de Ag. de 2019
i have a matrix like given below:
X=[1 5 3;
1 5 4;
1 5 3]
i have to compre the elements as X(1,1)=X(2,1)=X(3,1) if its same then result must be that value i.e. (X1=1,X2=5) but if not same then the value must be what is the majority otherwise display erroe
for ex: X(1,3)~=X(2,3)=X(3,3)then X3=3
  2 comentarios
Rik
Rik el 28 de Ag. de 2019
What have you tried so far?
PRAVEEN GUPTA
PRAVEEN GUPTA el 28 de Ag. de 2019
i am not getting only for "ex: X(1,3)~=X(2,3)=X(3,3)then X3=3"
first case i have done using if loop

Iniciar sesión para comentar.

Respuesta aceptada

Guillaume
Guillaume el 28 de Ag. de 2019
So basically, you want
mode(X, 1)
  3 comentarios
Rik
Rik el 28 de Ag. de 2019
Can you explain why not?
Guillaume
Guillaume el 28 de Ag. de 2019
must be what is the majority
This is the exact definition of mode. Of course, if the values are all the same, that single value is also the mode.
So, indeed as Rik says, explain why not?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by