[Ask Help] - Convert Negative Commas Decimal into Single Binary
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Hello,
Is anyone please could help me to convert this data from (Negative Commas Decimal).
Maximum set to '1' and other set to '0 or zero'.
This is my data:
data = [1.295175 -0.021158 -0.274017]
And i wanna convert into single binary like this :
data = [ 1 0 0 ]
Thanks.
Accepted Answer
Arif Hoq
on 8 Dec 2022
data = [1.295175 -0.021158 -0.274017];
data(data<0)=0;
data(data>1)=1
data = 1×3
1 0 0
8 Comments
Hilmi
on 8 Dec 2022
this is my data

and i'm still getting error using this :
data(data<0)=0;
data(data>1)=1
data = 1x3

please help me,
thanks...
what kind of binary value do you want for [0.262483 0.749615]? 0 or 1?
data=[0.262483 0.749615 -0.012098];
data(data<0)=0;
data(data>0 & data<1)=1;
data(data>1)=1
data = 1×3
1 1 0
Hilmi
on 8 Dec 2022
thanks, now i have data like this, and i wanna convert to [ 1 0 0 ]
0.262483
0.749615
-0.012098
just only convert into "1" on maximum data...
and convert others convert into "0/zero"....
Arif Hoq
on 8 Dec 2022
I don't get your logic. 0.749615 is greater than 0.262483.
if you want the maximum data into 1 then [0.262483 0.749615 -0.012098] would be [0 1 0].
Hilmi
on 8 Dec 2022
oh ya i'm sorry [0.262483 0.749615 -0.012098] should be [0 1 0].
maybe i just wanna convert data like that
- only convert data maximum into '1'
- and convert others into '0'
and i've many data below:
data1 =
0.2114
-0.1044
0.8930
data2 =
0.1854
0.3776
0.4370
data3 =
0.2857
-0.5430
1.2574
data4 =
0.026814
0.295099
0.678087
data5 =
0.1420
-0.1536
1.0116
what should i do? thankss...
Arif Hoq
on 8 Dec 2022
try this:
data1=[0.2114 -0.1044 0.8930];
[M I]=max(data1);
data1(I)=1;
data1(data1~=1)=0
data1 = 1×3
0 0 1
%% data2
data2 =[ 0.1854 0.3776 0.4370];
[M I]=max(data2);
data2(I)=1;
data2(data2~=1)=0
data2 = 1×3
0 0 1
%% data3
data3 =[ 0.2857 -0.5430 1.2574];
[M I]=max(data3);
data3(I)=1;
data3(data3~=1)=0
data3 = 1×3
0 0 1
Hilmi
on 8 Dec 2022
Hohoho wow.
Thank a lot, Arif Hoq.
It's all work well.
Arif Hoq
on 8 Dec 2022
my pleasure
More Answers (0)
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)