txt file to cell array to text file
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear all,
I have a matrix txt file with 384 rows and 12 columns (tab-formatted). Each column can have either numeric or string data. I want to import the matrix so that I can make loops and if-then opeations on single columns (changing numbers with strings, or execute math operations, for example).
I imported my data using tdfread and then convert it into a cellarray with struct2cell:
B = tdfread (filename, '\t');
D = struct2cell(B);
This would give me D=<12x1cell>
Now my questions:
(1) Is this procedure the best one?
(2) How can I loop within one of the nested cells, let's say n. 3 - which would correspond to column 3 in the orginal txt matrix?
(2) How can I then export the new modified cell-array to a txt file once again? Would fprintf be a good solution?
Sorry to be dumb!
Any help appreciated.
Best,
Udiubu
0 commentaires
Réponses (2)
hde
le 5 Mar 2012
3) I have previously used the following:
save example.txt D -ascii
This saves the array into a text file called example.txt.
0 commentaires
Voir également
Catégories
En savoir plus sur Data Type Conversion 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!