txt file to cell array to text file
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
hde
2012-3-5
3) I have previously used the following:
save example.txt D -ascii
This saves the array into a text file called example.txt.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!