read from a txt file

1 次查看(过去 30 天)
Alexandros
Alexandros 2011-11-25
I have a txt file that looks like
time1,system1,system2,system3
[sec],[m],[m],[m]
1 AM, 1,2,3
2 AM, 1,2,3
3 AM, 1,2,3
I want to take that into matlab and then transfer it to excel every cell under it
By doing
dir = fopen(text.txt)
D = textscan(dir, '%s %s %s %s', 'delimited', ',')
I get a 4 cell arrays which includes all the data. so cell 1 has all the colum for time 1, cell 2 all the column for system1 e.t.c
when i do xlswrite (test.xls, D, 1, 'A1') it doesn't want to paste it
Do you have any ideas? I could use the dlmread function (only for numerical data) but i really need to paste also the time1 column with AM or without AM i don't care. But dlmread doesnt work if there is text in there and it colides with AM
Any ideas Thank you
  1 个评论
Jan
Jan 2011-11-25
Instead of "it doesn't want to paste it" a copy of the error message would be more helpful. Do you have problems with the file name -forgot the quotes?- or with the data in D -no nested cells allowed-?

请先登录,再进行评论。

采纳的回答

Jan
Jan 2011-11-25
E = cat(2, D{:});
xlswrite('test.xls', E, 1, 'A1');
  1 个评论
Alexandros
Alexandros 2011-11-25
This is exactly what I needed.
Thank you so much

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by