Prev: Cleaning up Text
Next: FFT analysis
From: Oleg Komarov on 23 Jun 2010 12:18 Walter Roberson <roberson(a)hushmail.com> wrote in message <rkqUn.87015$HG1.12356(a)newsfe21.iad>... > Arild wrote: > > >> > 01.01.2005 00:00 23.6 25.7 etc. > >> > > So I'm using > >> > fid = fopen('filename.txt','r') > >> > C = textscan(fid, '%s %f %f') > > > If I use > > [day, month, year, remain] = textscan(date, '%f %f %f > > %s','delimiter','.'); > > I get error: > > First input must be of type double or string. > > I imagine it might be that the date/month/year are delimited by a '.', > > while there is just a whitespace between the year and '00:00'? > > You can use multiple delimiters, '.: ' or you can use width limitations > while reading: > > '%2u.%2u.%u %u:%u %f %f....' > > I have used a mix of fixed-width fields and indefinite width fields so > as to properly absorb the spaces. The '.' and ':' in the format will be > required to match literal '.' and ':' in the string. As suggested above: >> cellDates = {'01.01.2005 00:00'; '13.02.2007 00:00'}; [y,m,d] = datevec(cellDates,'dd.mm.yyyy HH:MM') y = 2005 2007 m = 1 2 d = 1 13 Oleg |