Filter löschen
Filter löschen

save text and data into ascii file

11 Ansichten (letzte 30 Tage)
Rok mr
Rok mr am 28 Okt. 2011
hi,
I have a problem to save structure into text file which could be later imported to some other programs.
structure:
data 3x5
textdata 1x1
I would like to save it into .dat file like this:
time(ms),flow,T p,T t,p gl,
+0.000,+2.625,+17.580,+17.896,+2.326
+1.000,+2.587,+17.583,+17.889,+2.325
+2.000,+2.625,+17.568,+17.896,+2.321
Hope you can help me.
Thanks for all your posts in advance!
Regards,
R
  2 Kommentare
Jan
Jan am 28 Okt. 2011
"data 3x5 textdata 1x1" is not clear. Please post the Matlab code, which creates the struct - most likely using dunmmy values using RAND is sufficient.
Fangjun Jiang
Fangjun Jiang am 28 Okt. 2011
I guess, Jan, if you save the OP's data above in a text file without empty lines in between, then use importdata, you'll get a structure with .data and .textdata like that.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 28 Okt. 2011
Use fprintf(). Assume the name of the structure is 'd'.
fid=fopen('out.dat','wt');
fprintf('%s\n',d.textdata{1});
fprintf('%f,%f,%f,%f,%f\n',d.data');
fclose(fid);

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by