Filter löschen
Filter löschen

apply a different condition to 2 columns

1 Ansicht (letzte 30 Tage)
Andres Serrano
Andres Serrano am 2 Nov. 2018
Kommentiert: madhan ravi am 2 Nov. 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 Kommentare
Andres Serrano
Andres Serrano am 2 Nov. 2018
Hi Stephan!
Andres Serrano
Andres Serrano am 2 Nov. 2018
You are right Stephan, my bad!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Bruno Luong
Bruno Luong am 2 Nov. 2018
Bearbeitet: Bruno Luong am 2 Nov. 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
>>

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by