[Top][All Lists]

[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 (Windows/20061207)

the_verge wrote:

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:


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


reply via email to

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