Conversion of 2000x3 decimal matrix .txt file into binary 2000x3 .txt file
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Stephan
le 13 Oct 2019
Modifié(e) : Stephan
le 13 Oct 2019
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!