Borrar filtros
Borrar filtros

apply a different condition to 2 columns

1 visualización (últimos 30 días)
Andres Serrano
Andres Serrano el 2 de Nov. de 2018
Comentada: madhan ravi el 2 de Nov. de 2018
Hi guys. I have a matrix 2*2 and I want to apply 1 condition to each column to get a new matrix of the same size. EX a= '0.4317' '0.9203' '0.7011' '0.4612' Condition column 1 = if X<0.5 then Y=1 otherwise y=0. the condition for the second column would be the opposite. following those conditions matrix b= '1' '1' '1''0'.
  3 comentarios
Andres Serrano
Andres Serrano el 2 de Nov. de 2018
Hi Stephan!
Andres Serrano
Andres Serrano el 2 de Nov. de 2018
You are right Stephan, my bad!

Iniciar sesión para comentar.

Respuesta aceptada

Bruno Luong
Bruno Luong el 2 de Nov. de 2018
Editada: Bruno Luong el 2 de Nov. de 2018
Example from you attached mfile
>> a = [...
0.4317 0.9203
0.0155 0.0527
0.9841 0.7379
0.1672 0.2691
0.1062 0.4228 ]
a =
0.4317 0.9203
0.0155 0.0527
0.9841 0.7379
0.1672 0.2691
0.1062 0.4228
>> a <= [0.5 0.7]
ans =
5×2 logical array
1 0
1 1
0 0
1 1
1 1
>>

Más respuestas (0)

Categorías

Más información sobre Data Types 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