Info
This question is closed. Reopen it to edit or answer.
Going from a string to a matrix
1 view (last 30 days)
Show older comments
I want to use information from a .dat document, which is the outcome of some experiments. I used the following code to put the information in an array:
fid = fopen('glhedata.dat'); n = 1; textline = {}; while( ~feof(fid) ) textline(n,1) = {fgetl(fid)}; n = n + 1; end fclose(fid);
For example, on row 36 I got a string: ('january 00.0000 5.22222 6.32555 2.5548'). I want to put this string in a matrix (or vector) like this: A = ('january'; 00.000 ; 5.22222; 6.325555; 2.5548;), so that i can use the numerical values and january stays a string. I tried to use sscanf, but that doesnt seem to work. Can anybody help me?
Nick
0 Comments
Answers (1)
Azzi Abdelmalek
on 27 Nov 2013
s='january 00.0000 5.22222 6.32555 2.5548'
out=regexp(s,'\s+','split')
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!