How to categorize elements in a matrix based on positive or negative terms and assign them '0' and '1'
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ASHA PON
am 1 Dez. 2022
Kommentiert: ASHA PON
am 2 Dez. 2022
I am having a column matrix say 7*1. Now, i need to assign '0' to negative elements and '1' to positive elements in the matrix. Thank you in advance.
For example:
A=[ 0.468505878281799
-1.90580778081907
-2.25397431420907
-3.46546394734966
0.488991442582022
-1.68349064240944
0.377334138950664]
Expected output:
B= [ 1; 0; 0; 0; 1; 0; 1]
0 Kommentare
Akzeptierte Antwort
David Hill
am 1 Dez. 2022
A=[ 0.468505878281799
-1.90580778081907
-2.25397431420907
-3.46546394734966
0.488991442582022
-1.68349064240944
0.377334138950664];
B=A>0
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!