How do i export text file into matrix with 4 different data? Pls advice how should the code will be ?

2 次查看(过去 30 天)
Time (Seconds): 0.00 Ground Speed (km/h): 171.2898382 G Force Long (G): 0.27 G Force Lat (G): 0.1856280
Time (Seconds): 0.02 Ground Speed (km/h): 171.4937546 G Force Long (G): 0.27 G Force Lat (G): 0.1856280
Time (Seconds): 0.04 Ground Speed (km/h): 171.6976711 G Force Long (G): 0.27 G Force Lat (G): 0.1846300
Time (Seconds): 0.06 Ground Speed (km/h): 171.9015876 G Force Long (G): 0.27 G Force Lat (G): 0.1846300
Time (Seconds): 0.08 Ground Speed (km/h): 172.1055041 G Force Long (G): 0.27 G Force Lat (G): 0.1836320
Time (Seconds): 0.10 Ground Speed (km/h): 172.3094205 G Force Long (G): 0.27 G Force Lat (G): 0.1836320
Time (Seconds): 0.12 Ground Speed (km/h): 172.5133370 G Force Long (G): 0.26 G Force Lat (G): 0.1836320
Time (Seconds): 0.14 Ground Speed (km/h): 172.7172535 G Force Long (G): 0.26 G Force Lat (G): 0.1846300
Time (Seconds): 0.16 Ground Speed (km/h): 172.8192117 G Force Long (G): 0.25 G Force Lat (G): 0.1846300
Time (Seconds): 0.18 Ground Speed (km/h): 173.0231282 G Force Long (G): 0.25 G Force Lat (G): 0.1856280
  2 个评论
Jan
Jan 2015-5-4
编辑:Jan 2015-5-4
This is not twitter, so please omit the # in the tags. The tags are a comma separated list of terms, which should help to find the topic of your question. Now this is found, if any other user has a problem concerning "#text #export #dlmread #data #dlmwrite #matrix #matrice", but this is very unlikely.
The question is not clear. What did you post here? In which form is it stored in your code? What is the wanted result?

请先登录,再进行评论。

回答(1 个)

Joseph Cheng
Joseph Cheng 2015-5-5
编辑:Joseph Cheng 2015-5-5
To answer your question, it's as simple as reading the documentation on fprintf or dlmwrite
The text file can be read in with fscanf or fgetl , and then parsed out with regexp or strfind to be then written with fprintf or dlmwrite.
Example of using regexp to obtain number. **note does not detect the - sign
fileID = fopen('track.txt');
pat = '((\d+,)*\d+(\.\d*))'
while ~feof(fid)
line = fgetl(fileID);
n = regexp(line, pat, 'match')
end
fclose(fileID);

类别

Help CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by