help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read file, given a non-octave header


From: Bill Denney
Subject: Re: read file, given a non-octave header
Date: Sat, 27 Jan 2007 13:54:11 -0500
User-agent: Thunderbird 1.5.0.9 (Windows/20061207)

the_verge wrote:
Thomas,

Great!  That works well.  Now, I'm having another problem, that's somewhat
related:  One of my columns of data is a number with commas for thousands
separators.  How do I convert a string like: '1,200' to an integer, or
float: 1200.00

str2double('1,200')  comes close, but it reads the comma as a column
separator, so that I get:

octave:6>str2double('1,200')

ans = 1.00 200.00
You can do this (it will require looping over the cell columns with commas in them):

octave:7> a = {'1,200' '130'}
a =

{
 [1,1] = 1,200
 [1,2] = 130
}

octave:8> b = str2num(strrep(a{1}, ",", ""))
b =  1200
octave:9> class(b)
ans = double

Bill


reply via email to

[Prev in Thread] Current Thread [Next in Thread]