Filter löschen
Filter löschen

Converting .mat file with integer values to .dat causing wrong placement of the floating point

2 Ansichten (letzte 30 Tage)
Hi,
I am using Matlab R2018b. I have a mat file that looks like the following:
TimeSeries1 = [10 100; 11 101; 12 101; 13 102; etc] but longer and if I open I can see that the values seem correct
Col1 Col2
11 100
12 101
13 101
14 102
....
I tried to convert the .mat file to a .dat file as one of the algorithm I need to use requires a .dat file. So I did the following:
save TimeSeries1.dat TimeSeries1 -ascii
When i double clicked the dat file and opened it, it looks like this:
e00 e1
1.1 1.00
1.2 1.01
1.3 1.01
1.4 1.02
I don't understand why the '.' after the first character even though the data in the .mat file doesn't have that.
Do I do sth wrong?
Thanks for the help.

Antworten (1)

Stephen23
Stephen23 am 6 Feb. 2020
Bearbeitet: Stephen23 am 6 Feb. 2020
save writes text files using exponential notation. If you don't want exponential notation, don't use save
In any case, using csvwrite or dlmwrite or writematrix or writetable etc. are preferred for writing text files. Or for full control over the file format, use low-level fprintf.
  2 Kommentare
Suzan Doornwaard
Suzan Doornwaard am 6 Feb. 2020
Thanks for the prompt answer Stephen!
I checked the functions you've suggested and already the dlmwrite function does exactly what I wanted.
I simply typed the command below and problem solved. Cheers.
dlmwrite('TimeSeries1.dat', TimeSeries1);
Stephen23
Stephen23 am 6 Feb. 2020
Bearbeitet: Stephen23 am 6 Feb. 2020
@Suzan Doornwaard: Please remember to accept my answer if it helpd you!

Melden Sie sich an, um zu kommentieren.

Kategorien

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

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by