The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: help reading csv file with string
Replies: 3   Last Post: Apr 2, 2012 7:30 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Walter Roberson

Posts: 7,678
Registered: 1/20/06
Re: help reading csv file with string
Posted: Dec 13, 2010 2:32 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 13/12/10 1:16 AM, Anonymous wrote:
> Hi, im not really good at Matlab so please bear with me, here's my
> problem: I have a csv file that contains a plenty of row data like this
> 1,10/9/2010
> 05:42:59:390,0.25873534,0,0.25053943,0,0.26066645,0,0.26313331,0,0.6127435,0,0.015781,0,0.016664,0,0.016033,0,0.016664,0
> I would like to read the data in matlab and transform it into a matrix.
> But matlab only reads csv files with pure numeric or text, how can i
> remove the string section? What commands should i use? Thanks

I advise using textscan() with a 'Delimiter' of ',' and 'Whitespace' set
to '' so that the space between the date and time is not treated as
ending that particular cell. Use %f as the format for floating point
numbers (or integers that you want to store as double precision), use %s
for the date and time. It appears to me that an appropriate format would
be ['%f%s', repmat('%f',1,18)]

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.