How do I read a text file with certain format line by line with each line of different length?
Mostra commenti meno recenti
I just come across a problem that requires reading a vertex-list weighted map. It is just simply a bunch of lines with each line's number as the order and the rest is in pairs separated by comma. So it looks like this:
1 34,45 56,43 23,34
2 34,56 42,23 33,2 54,23
3 43,22
...
What I want to do is to read each row into an array.For example, arr(3,:)=[43,22] arr(2,:)=[34,56,42,23,33,3,354,23] But I don't know to implement it. Can someone help me with that?
1 Commento
You may find the following thread interesting:
Note that if you really have commas as decimal separator, you may want to replace them before parsing, e.g.
content = fileread( 'MyData.txt' ) ;
content(content == ',') = '.' ;
data = ...
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Text Data Preparation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!