read from a txt file

1 view (last 30 days)
Alexandros
Alexandros on 25 Nov 2011
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 Comment
Jan
Jan on 25 Nov 2011
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-?

Sign in to comment.

Accepted Answer

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

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!