Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!h5g2000yqh.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Decimal Separator
Date: Fri, 21 Nov 2008 15:41:27 -0800 (PST)
Organization: http://groups.google.com
Lines: 22
Message-ID: <21a1b440-a74e-426d-872a-02aa2fa79d44@h5g2000yqh.googlegroups.com>
References: <gg6opu$1i2$1@fred.mathworks.com>
NNTP-Posting-Host: 77.17.63.197
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1227310887 15178 127.0.0.1 (21 Nov 2008 23:41:27 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 21 Nov 2008 23:41:27 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: h5g2000yqh.googlegroups.com; posting-host=77.17.63.197; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET 
	CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:502440


On 21 Nov, 17:49, "Ellen Arens" <ellen.e.ar...@nasa.gov> wrote:
> How can I import numeric data that uses a comma as a decimal separator? =
=A0For example, a table of 640 by 480 numberic valves.

The general idea would be to read a full line, replace
commas by dots and then convert to numbers. Something
like (not tested!):

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fid =3D fopen('file.txt');
A =3D[];
while(~feof(fid))
    s =3D fgetl(fid);       % Read line from file
    cidx =3D find(s=3D=3D',');  % Find all commas...
    s(cidx)=3D'.';          % ...and replace with dots
    a=3Dsscanf('%f',s,inf); % Read in as numbers
    A =3D [A;a'];           % Append to result matrix
end
fclose(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Rune