Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Jan
Jan il 4 Mag 2015
Modificato: Jan il 4 Mag 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 il 5 Mag 2015
Modificato: Yeap Jia Wei il 5 Mag 2015
Dear Simon, this is the attached text file. Pleases advice on how to export it to matlab as matrix as code. Ty!

Accedi per commentare.

Risposte (1)

Joseph Cheng
Joseph Cheng il 5 Mag 2015
Modificato: Joseph Cheng il 5 Mag 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);

Community Treasure Hunt

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

Start Hunting!

Translated by