Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Textread
Date: Thu, 2 Jul 2009 08:34:02 +0000 (UTC)
Organization: ASL
Lines: 23
Message-ID: <h2hrdq$7r4$1@fred.mathworks.com>
References: <h2favd$6b6$1@fred.mathworks.com> <op.uwellojea5ziv5@uthamaa.dhcp.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246523642 8036 172.30.248.35 (2 Jul 2009 08:34:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 2 Jul 2009 08:34:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1885308
Xref: news.mathworks.com comp.soft-sys.matlab:552293


> > I tried:
> >
> >>> data = importdata('data_in.dat');
> >>> dlmwrite('data_out.dat',data,'.')
> > ??? Error using ==> dlmwrite
> > The input cell array can not be converted to a matrix.
> >
> > The name of the data file i loaded was data_in.dat
> 
> Did you inspect the data you get from IMPORTDATA. (I would recommend using  
> FOPEN, TEXTSCAN)
> 
> Is it a cell array of strings? 

Right, I see now that your comma isn't a delimiter but a decimal point! Import data assumes that the comma is a delimiter, so if one of your values were missing the decimal point then your row sizes would be different and wouldn't fit into a rectangular matrix; I guess this is why you got your error or, as Rune suggested, because there was something that was interpreted as a string.

> fid = fopen('data_in.dat', 'rb+');
> s = fread(fid, inf, 'uchar');
> fseek(fid, 0, -1);
> fwrite(fid, strrep(s, ',', '.'), 'uchar');
> fclose(fid);

Works for me!