Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Stephen23
Stephen23 il 6 Feb 2020
Modificato: Stephen23 il 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 Commenti
Suzan Doornwaard
Suzan Doornwaard il 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 il 6 Feb 2020
Modificato: Stephen23 il 6 Feb 2020
@Suzan Doornwaard: Please remember to accept my answer if it helpd you!

Accedi per commentare.

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by