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

Answers (1)

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

This question is closed.

Asked:

on 27 Nov 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!