Filter löschen
Filter löschen

How to convert character column to 4 byte (total 32 bits) data?

8 Ansichten (letzte 30 Tage)
Dohee Kim
Dohee Kim am 11 Aug. 2022
Beantwortet: David Hill am 11 Aug. 2022
Hi, Thank you fo much for get interest in this,
I have a numbers indicating instrument status in timetable.
For example, now it looks like this:
Time Var1
20220804 00:00:01 15226547
20220804 00:00:02 3226557
... ....
These numbers in Var1 (possibly characters, since my instrument manual saids it as 'words') should be 4 bytes and each byte has 8 bits that includes different information as 1 or 0 respectively. So in total I should have 32 digits of 1s and 0s (like binary form).
What I want to get is:
Time Var1 Bit1 Bit2 Bit3 Bit4 ... Bit 32
20220804 00:00:01 15226547 1 0 1 0 1
20220804 00:00:02 3226557 0 0 1 0 1
... .... ....
(FYI, I believe first row should be look like 00100100 according to actual instrument setup.)
I tried to change this Var1 numbers in 32digit binary form, but it seems not the correct way.
Also I tried some functions like typecast, uint32, and so on... but it is hard to figure out..
I attached Status.mat file.
Do you have any idea to solve this out?

Antworten (1)

David Hill
David Hill am 11 Aug. 2022
dec2bin(15226547,32)-'0'
ans = 1×32
0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 0 1 1 0 0

Kategorien

Mehr zu MATLAB 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!

Translated by