txt file to cell array to text file

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

답변 (2개)

hde
hde 2012년 3월 5일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

Ubu
2012년 3월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by