Got Questions? Get Answers.
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:
num2str error(R2007b bug?)

Subject: num2str error(R2007b bug?)

From: foxyjazz@gmail.com

Date: 11 Sep, 2007 01:45:45

Message: 1 of 8

"num2str" generates following error in R2007b.
---
??? Error: File: num2str.m Line: 150 Column: 13
 "u" previously appeared to be used as a function or command,
conflicting with its use
 here as the name of a variable.
 A possible cause of this error is that you forgot to initialize the
 variable, or you have initialized it implicitly using load or eval.
---

It works in R2007a. Is it R2007b bug?

Subject: num2str error(R2007b bug?)

From: Steven Lord

Date: 11 Sep, 2007 04:07:36

Message: 2 of 8


<foxyjazz@gmail.com> wrote in message
news:1189475145.122254.233580@y42g2000hsy.googlegroups.com...
> "num2str" generates following error in R2007b.
> ---
> ??? Error: File: num2str.m Line: 150 Column: 13
> "u" previously appeared to be used as a function or command,
> conflicting with its use
> here as the name of a variable.
> A possible cause of this error is that you forgot to initialize the
> variable, or you have initialized it implicitly using load or eval.
> ---
>
> It works in R2007a. Is it R2007b bug?

I don't see anything offhand that indicates that you should receive this
error. Can you post your NUM2STR call and the inputs with which you can
reproduce this error?

--
Steve Lord
slord@mathworks.com

Subject: num2str error(R2007b bug?)

From: foxyjazz@gmail.com

Date: 11 Sep, 2007 04:38:04

Message: 3 of 8

"Steven Lord" <sl...@mathworks.com> wrote:
> I don't see anything offhand that indicates that you should receive this
> error. Can you post your NUM2STR call and the inputs with which you can
> reproduce this error?


The result in R2007b is as follows.

>> num2str(1)
??? Error: File: num2str.m Line: 150 Column: 13
 "u" previously appeared to be used as a function or command,
conflicting with its use
 here as the name of a variable.
 A possible cause of this error is that you forgot to initialize the
 variable, or you have initialized it implicitly using load or eval.


inst2str() and str2num() work well.

>> int2str(1)
ans = 1

>> str2num('1')
ans = 1

foxyjazz@gmail.com

Subject: num2str error(R2007b bug?)

From: marky

Date: 11 Sep, 2007 08:11:32

Message: 4 of 8

Steven Lord wrote:
> <foxyjazz@gmail.com> wrote in message
> news:1189475145.122254.233580@y42g2000hsy.googlegroups.com...
>> "num2str" generates following error in R2007b.
>> ---
>> ??? Error: File: num2str.m Line: 150 Column: 13
>> "u" previously appeared to be used as a function or command,
>> conflicting with its use
>> here as the name of a variable.
>> A possible cause of this error is that you forgot to initialize the
>> variable, or you have initialized it implicitly using load or eval.
>> ---
>>
>> It works in R2007a. Is it R2007b bug?
>
> I don't see anything offhand that indicates that you should receive this
> error. Can you post your NUM2STR call and the inputs with which you can
> reproduce this error?
>

Interesting. I get this:


 >> version, computer, num2str(randn(2,2),3)

ans =

7.4.0.287 (R2007a)


ans =

SOL64

??? Error: File: /p4/matlab-7.4.0/toolbox/matlab/strfun/num2str.m Line: 150 Column: 13
  "u" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable.
  A possible cause of this error is that you forgot to initialize the
  variable, or you have initialized it implicitly using load or eval.


 >>

Subject: num2str error(R2007b bug?)

From: us

Date: 11 Sep, 2007 08:32:45

Message: 5 of 8

foxyjazz:
<SNIP <num2str> problem...

> "num2str" generates following error in R2007b.
> ??? Error: File: num2str.m Line: 150 Column: 13
> "u" previously appeared to be used as a function
> It works in R2007a. Is it R2007b bug...

the reason for this message: you have a function <u>
somewhere in your path

     which u -all

it seems that r2007b is very aggressively now trying to
prevent the well known function/variable name conflict...

note: this only happens with conflicts between SINGLE
letter function/variable names...

quick and dirty workarounds
- rename your <u.m>...
- copy <num2str> into a path, which is at the top of your
search path, and replace the <u>s...

us

Subject: num2str error(R2007b bug?)

From: foxyjazz@gmail.com

Date: 11 Sep, 2007 08:45:12

Message: 6 of 8

I understood it.

Because there was a function named "u.m" in a work directory,
malfunction was taking place.

But, why does not it get up in R2007a?

Subject: num2str error(R2007b bug?)

From: Loren Shure

Date: 11 Sep, 2007 12:04:53

Message: 7 of 8

In article <fc5jrd$gih$1@fred.mathworks.com>, us@neurol.unizh.ch says...
> foxyjazz:
> <SNIP <num2str> problem...
>
> > "num2str" generates following error in R2007b.
> > ??? Error: File: num2str.m Line: 150 Column: 13
> > "u" previously appeared to be used as a function
> > It works in R2007a. Is it R2007b bug...
>
> the reason for this message: you have a function <u>
> somewhere in your path
>
> which u -all
>
> it seems that r2007b is very aggressively now trying to
> prevent the well known function/variable name conflict...
>
> note: this only happens with conflicts between SINGLE
> letter function/variable names...
>
> quick and dirty workarounds
> - rename your <u.m>...
> - copy <num2str> into a path, which is at the top of your
> search path, and replace the <u>s...
>
> us
>

We'll check into this.

--
Loren
http://blogs.mathworks.com/loren/

Subject: num2str error(R2007b bug?)

From: Yuri Geshelin

Date: 16 Dec, 2010 23:46:05

Message: 8 of 8

 foxyjazz@gmail.com wrote in message <1189500312.175368.90770@57g2000hsv.googlegroups.com>...
> I understood it.
>
> Because there was a function named "u.m" in a work directory,
> malfunction was taking place.
>
> But, why does not it get up in R2007a?
>

There are 2 reasons for not running into this problem in earlier versions. The first one is described in your output:

Reason #1. before even executing this function, R2007b checks the code to see if there is a situation, in which you would reference an undefined variable (in this case ‘u’) and then attempt to assign something to this variable. R2007a and earlier versions did not do this. So R2007b sees this line

pads(length(u)) = true;

and because variable ‘u’ is undefined, R2007b thinks: is there really a function called ‘u’? It then checks the path. If such function exists, it issues the error message. Otherwise, for some reason, it is silent. (It could have warned you all the same that you are referencing an undefined variable, which is not a function.)

As I said, this all happens even before the execution of NUM2STR.

Now you may think: but then in the earlier version, at the execution stage, the code should have bumped into the reference to ‘u’ and issued another error message. Here we are getting at the reason #2, a simple one. Most likely, your algorithm has never made it to that line of code, because when the input argument is not a complex number, function NUM2STR returns the output value and terminates pretty quickly.

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