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

2 次查看(过去 30 天)
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.

回答(1 个)

Stephen23
Stephen23 2020-2-6
编辑:Stephen23 2020-2-6
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 个评论
Suzan Doornwaard
Suzan Doornwaard 2020-2-6
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);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by