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:
File writing

Subject: File writing

From: Snow White

Date: 21 Jul, 2009 17:07:01

Message: 1 of 4

Hello

I get the following error for the following code. All that i do is pass values to a functions the values are fine before passing but when they r passed into the function to be written into a text file i get boxes and this warning. But not for all the values just some values.

Warning: Out of range or non-integer values truncated during conversion to character.

for r_s=1:root_size
% reciprocal_root(x,y,r_s,f_flag)=1/root_r(x,y,r_s,f_flag);
                fprintf(fid,num2str(reciprocal_root(x,y,r_s,f_flag)));
                fprintf(fid,'\n');
            end

Bye

Subject: File writing

From: us

Date: 21 Jul, 2009 17:29:02

Message: 2 of 4

"Snow White" <gulesaman@gmail.com> wrote in message <h44sjl$ncf$1@fred.mathworks.com>...
> Hello
>
> I get the following error for the following code. All that i do is pass values to a functions the values are fine before passing but when they r passed into the function to be written into a text file i get boxes and this warning. But not for all the values just some values.
>
> Warning: Out of range or non-integer values truncated during conversion to character.
>
> for r_s=1:root_size
> % reciprocal_root(x,y,r_s,f_flag)=1/root_r(x,y,r_s,f_flag);
> fprintf(fid,num2str(reciprocal_root(x,y,r_s,f_flag)));
> fprintf(fid,'\n');
> end
>
> Bye

what are
- x
- y
- r_s
- f_flag
what does compute
- reciprocal_root
where does the error message come from

+, most importantly, don't waste CSSMers time with such vaguely phrased problems...

us

Subject: File writing

From: Snow White

Date: 21 Jul, 2009 18:06:06

Message: 3 of 4

sorry if i wasted your time...

the problem arises when i use num2str. i get this warning. Its not an error but a warning..
 
the following is written to the file

refractive index=



reciprocal refractive index=




"us " <us@neurol.unizh.ch> wrote in message <h44tsu$he2$1@fred.mathworks.com>...
> "Snow White" <gulesaman@gmail.com> wrote in message <h44sjl$ncf$1@fred.mathworks.com>...
> > Hello
> >
> > I get the following error for the following code. All that i do is pass values to a functions the values are fine before passing but when they r passed into the function to be written into a text file i get boxes and this warning. But not for all the values just some values.
> >
> > Warning: Out of range or non-integer values truncated during conversion to character.
> >
> > for r_s=1:root_size
> > % reciprocal_root(x,y,r_s,f_flag)=1/root_r(x,y,r_s,f_flag);
> > fprintf(fid,num2str(reciprocal_root(x,y,r_s,f_flag)));
> > fprintf(fid,'\n');
> > end
> >
> > Bye
>
> what are
> - x
> - y
> - r_s
> - f_flag
> what does compute
> - reciprocal_root
> where does the error message come from
>
> +, most importantly, don't waste CSSMers time with such vaguely phrased problems...
>
> us

Subject: File writing

From: Snow White

Date: 22 Jul, 2009 12:21:02

Message: 4 of 4

I do the following simple assignment
AA_reciprocal_root(x,y,r_x,f_flag)=reciprocal_root(x,y,r_x,f_flag);

and AA_reciprocal_root(x,y,r_x,f_flag) returns an empty variable with space assigned to it.
AA_reciprocal_root(x,y,r_x,f_flag)

ans =

 

just an example... :/

"Snow White" <gulesaman@gmail.com> wrote in message <h4502e$7n5$1@fred.mathworks.com>...
> sorry if i wasted your time...
>
> the problem arises when i use num2str. i get this warning. Its not an error but a warning..
>
> the following is written to the file
>
> refractive index=
>
>
>
> reciprocal refractive index=
> 
> 
> 
>
> "us " <us@neurol.unizh.ch> wrote in message <h44tsu$he2$1@fred.mathworks.com>...
> > "Snow White" <gulesaman@gmail.com> wrote in message <h44sjl$ncf$1@fred.mathworks.com>...
> > > Hello
> > >
> > > I get the following error for the following code. All that i do is pass values to a functions the values are fine before passing but when they r passed into the function to be written into a text file i get boxes and this warning. But not for all the values just some values.
> > >
> > > Warning: Out of range or non-integer values truncated during conversion to character.
> > >
> > > for r_s=1:root_size
> > > % reciprocal_root(x,y,r_s,f_flag)=1/root_r(x,y,r_s,f_flag);
> > > fprintf(fid,num2str(reciprocal_root(x,y,r_s,f_flag)));
> > > fprintf(fid,'\n');
> > > end
> > >
> > > Bye
> >
> > what are
> > - x
> > - y
> > - r_s
> > - f_flag
> > what does compute
> > - reciprocal_root
> > where does the error message come from
> >
> > +, most importantly, don't waste CSSMers time with such vaguely phrased problems...
> >
> > 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