Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
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 commentaires
Jan
Jan le 4 Mai 2015
Modifié(e) : Jan le 4 Mai 2015
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?
Yeap Jia Wei
Yeap Jia Wei le 5 Mai 2015
Modifié(e) : Yeap Jia Wei le 5 Mai 2015
Dear Simon, this is the attached text file. Pleases advice on how to export it to matlab as matrix as code. Ty!

Connectez-vous pour commenter.

Réponses (1)

Joseph Cheng
Joseph Cheng le 5 Mai 2015
Modifié(e) : Joseph Cheng le 5 Mai 2015
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);

Catégories

En savoir plus sur Text Data Preparation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by