I am trying to read and convert this textfile into a cell array, help!
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Time: 0sec
Latitude: 57.45308558deg
Longitude: 25.113673210deg
This is my code so far:
FileID = fopen('data1.txt');
Data = textscan(FileID,'Time: %fsec \n Latitude: %fdeg \n Longitude: %fdeg \n');
In the resultant cell array the first %f (for time) is displayed but the rest are coming up as empty spaces eg. '[]' How can I make it read the Lat/Long numbers as well? Thanks!
Answers (1)
Azzi Abdelmalek
on 6 May 2016
FileID = fopen('data1.txt')
s = textscan(FileID,'%s');
fclose(FileID)
out=reshape([s{:}],2,[])
2 Comments
Isaac Dunne
on 6 May 2016
Azzi Abdelmalek
on 6 May 2016
add
out=regexprep(out,'sec|deg','')
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!