Conversion of 2000x3 decimal matrix .txt file into binary 2000x3 .txt file

2 次查看(过去 30 天)
To begin, I have 2000x3 matrix .txt file that contains decimal numbers within, so I want to convert all decimal values to binary representation of them. How can I do that in Matlab? Thanks in advance!
e.g
6 6 13
2 6 46
4 5 10
20 30 70
10 24 182
80 44 446
19 13 940
18 9 15
60 33 16
4 28 220
2 6 46
30 26 53
16 8 98
10 24 250
18 20 512
....

采纳的回答

Stephan
Stephan 2019-10-13
编辑:Stephan 2019-10-13
This should work:
A = readmatrix('test_input_xyz.txt');
[sz1, sz2] = size(A);
A = reshape(A,[],1);
B = sdec2bin(A,12);
B = reshape(string(B),sz1,sz2);
writematrix(B,'2_complement_values.txt','Delimiter','tab')
Note that i attached a .m-file which is needed. I loaded it down from here:
I checked one sample here:
which worked for me - but check results, since you work with a function from the web - not an inbuilt Matlab function.
  7 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by