필터 지우기
필터 지우기

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);
Stephen23
Stephen23 2020년 2월 6일
편집: Stephen23 2020년 2월 6일
@Suzan Doornwaard: Please remember to accept my answer if it helpd you!

댓글을 달려면 로그인하십시오.

카테고리

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