txt file to cell array to text file

2 visualizaciones (últimos 30 días)
Ubu
Ubu el 5 de Mzo. de 2012
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

Respuestas (2)

hde
hde el 5 de Mzo. de 2012
3) I have previously used the following:
save example.txt D -ascii
This saves the array into a text file called example.txt.

Ubu
Ubu el 5 de Mzo. de 2012

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by