Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

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.

Contact us