Filter löschen
Filter löschen

read from a txt file

1 Ansicht (letzte 30 Tage)
Alexandros
Alexandros am 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 Kommentar
Jan
Jan am 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-?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by