How to read Binary from a txt file and assign it to row vector
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How can I read each line and store it in an array?
txt file:
00001
1000111
0.923 %this is a float
I want to read them as:
A=[0 0 0 0 1]
B=[1 0 0 0 1 1 1]
C=0.923
2 commentaires
Réponse acceptée
dpb
le 15 Déc 2019
Will have to read as char() and convert. For the one record, first cell...
>> x=textscan(s,'%s %s %f');
>> A=str2num(char(x{1}).')
ans =
0
0
0
0
1
>>
If the fields are fixed length, you can play games with counted %c fields or you can do similar type punning on the file image directly in memory.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Import and Export dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!