필터 지우기
필터 지우기

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?
Yeap Jia Wei
Yeap Jia Wei 2015년 5월 5일
편집: Yeap Jia Wei 2015년 5월 5일
Dear Simon, this is the attached text file. Pleases advice on how to export it to matlab as matrix as code. Ty!

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

답변 (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