Thread Subject: Function is not defined for 'cell' inputs.

Subject: Function is not defined for 'cell' inputs.

From: Kwon soon_mo

Date: 6 Jun, 2009 04:10:18

Message: 1 of 3

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

Subject: Function is not defined for 'cell' inputs.

From: Sadik

Date: 6 Jun, 2009 08:38:01

Message: 2 of 3

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

Subject: Function is not defined for 'cell' inputs.

From: us

Date: 6 Jun, 2009 11:22:01

Message: 3 of 3

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

or maybe this FEX contribution

http://www.mathworks.com/matlabcentral/fileexchange/23840

us

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
file exchange us 6 Jun, 2009 07:24:03
reference us 6 Jun, 2009 07:24:03
fex us 6 Jun, 2009 07:24:03
fprintf Kwon soon_mo 6 Jun, 2009 00:14:02
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com