Going from a string to a matrix

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

Risposte (1)

s='january 00.0000 5.22222 6.32555 2.5548'
out=regexp(s,'\s+','split')

Questa domanda è chiusa.

Richiesto:

il 27 Nov 2013

Chiuso:

il 20 Ago 2021

Community Treasure Hunt

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

Start Hunting!

Translated by