save workspace variables to *.dat along with int type

3 Ansichten (letzte 30 Tage)
David
David am 11 Mai 2011
How to save workspace to *.dat along with int type?
  1 Kommentar
Fangjun Jiang
Fangjun Jiang am 11 Mai 2011
What is the format of your *.dat file? Is it a text based file?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 11 Mai 2011
If you have a STRUCT or CELL in the workspace, what result do you expect after saving the data to a dat file with INT type? I cannot imagine, that there is a reliable solution for the general task.
Please post any details.
  2 Kommentare
David
David am 12 Mai 2011
>> a=[1 2 3 4]
a =
1 2 3 4
>> save a.dat a -ascii
>>
open the a.dat, the content is as below.
1.0000000e+000 2.0000000e+000 3.0000000e+000 4.0000000e+000
It is float format.
If I wish it is integer format in a.dat.
How to use save instruction?
Thank you.
Jan
Jan am 12 Mai 2011
a = int32(1:4);
save a.dat a -ascii
or:
fid = fopen('a.dat', 'w');
fprintf('%d ', a);
fclose(fid);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Workspace Variables and MAT Files 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