Overwriting Data in Text File with Content from Matlab Table, sample code attached!
显示 更早的评论
Hi Community, the following problem occured to me:
I have a .txt file with looks like:
Name: Drifter #92
Note: No notes
Serial Number#: 1
Address: 92
Accumulation of samples: 1
The measurement period: 10
Latitude: 0.000000
Longitude: 0.000000
Time UTC Water Air Chip
15.07.2015 12:24:47 +107.117 +106.925 +17.179 ...
15.07.2015 12:24:52 +107.116 +106.926 +17.124 ...
15.07.2015 12:24:57 +107.115 +106.935 +17.167 ...
15.07.2015 12:25:02 +107.116 +106.931 +17.131 ...
15.07.2015 12:25:07 +107.115 +106.924 +17.125 ...
15.07.2015 12:25:12 +107.113 +106.930 +17.107 ...
.
.
.
Due to speed issues I load only the first three columns into Matlab Workspace as a table, like this:
15.07.2015 12:24:47 +107.117 +106.925
15.07.2015 12:24:52 +107.116 +106.926
15.07.2015 12:24:57 +107.115 +106.935
15.07.2015 12:25:02 +107.116 +106.931
15.07.2015 12:25:07 +107.115 +106.924
15.07.2015 12:25:12 +107.113 +106.930
Now I calculate a little and change the date format:
2015-07-15 12:24:47 17.70681925195 17.0387490668112
2015-07-15 12:24:47 17.7042602411612 17.041305748443
2015-07-15 12:24:47 17.7017012303724 17.064315883129
2015-07-15 12:24:47 17.7042602411612 17.0540891566019
2015-07-15 12:24:47 17.7017012303724 17.0361923851795
2015-07-15 12:24:47 17.6965832087948 17.0515324749701
This data is saved in a cell array, where the first cell content is of type "string" and the others of type "double.
Finally I would like to replace the top three columns in the original textfile by the newly calculated ones, without overwriting the whole textfile.
I tried a lot with pointers to get to the right line in the textfile before wrting to it, but I don't come to a smart solution.
An exemplary .txt file, running sample code plus an import function generated by Matlab are attached.
Thanks for your help! With best regards, Helge.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Standard File Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
