|
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
|