Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Function is not defined for 'cell' inputs.
Date: Sat, 6 Jun 2009 08:38:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 59
Message-ID: <h0d9t9$lpv$1@fred.mathworks.com>
References: <h0cq7a$mgi$1@fred.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1244277481 22335 172.30.248.38 (6 Jun 2009 08:38:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 6 Jun 2009 08:38:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:545175


Hi Kwon,

In this line:

sort{1,3} = num2cell(mega);

you are assigning a cell to sort{1,3}, but in your fprintf, you are writing it as a string by saying %s. This is why you get the error. If mega is of type double, then you could say something like:

fprintf(fid,'%6.4f',mega);

If it is an integer, then

fprintf(fid,'%d',mega);

which all mean that you can directly input your variable. You should only be careful about what you put after the percent sign.

"Kwon soon_mo" <contrady@gmail.com> wrote in message <h0cq7a$mgi$1@fred.mathworks.com>...
> Hi
> read the txt file
> and array... and make txt file.
> but, cell is  not make the txt file...
> 
> help me....
> 
> error>>
> 
> ??? Error using ==> fprintf
> Function is not defined for 'cell' inputs.
> 
> Error in ==> earth3 at 53
> fprintf(fid,'%s' , sort{1,3});
> 
> 
> My code>>
> 
> 
> sort{1,1} = date;
> sort{1,2} = time;
> sort{1,3} = num2cell(mega);fid = fopen('earth2.txt');
> Earth = textscan(fid,'%s %s %f %s %s %s');
> fclose(fid);
> date = Earth{1};
> time = Earth{2};
> mega = Earth{3};  %ascending power
> wi = Earth{4};
> gy = Earth{5};
> area = Earth{6};
> 
> (array....)
> 
> sort{1,1} = date;
> sort{1,2} = time;
> sort{1,3} = num2cell(mega);
> fid = fopen('earth_new.txt','wt');
> fprintf(fid,'%s', sort{1,3});
> fclose(fid);
> 
> -----------------
> use sprintf??