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
....
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!