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:
Reference to a cleared variable

Subject: Reference to a cleared variable

From: trash

Date: 22 Jan, 2014 18:30:08

Message: 1 of 3

how can i fix this error?

When I give as a parameter GKN to the newff to be able use a loop
then I receive an error message "Reference to a cleared variable" at the newff line by referencing to GKN value.
How can i put this integer value to this function?

GKN=75; % this value will change in every iteration by a loop

net=newff(minmax(INP),[GKN 64],{'tansig','logsig'},'traingdx');

Anyone,can fix the error?

When i use an integer instead of GKN variable then everything works correctly.
like this

net=newff(minmax(INP),[75 64],{'tansig','logsig'},'traingdx');

Question:
How can i use a variable as a parameter in this location?

Subject: Reference to a cleared variable

From: Steven Lord

Date: 22 Jan, 2014 20:06:49

Message: 2 of 3


"trash " <trashall@gmail.com> wrote in message
news:lbp2ng$29b$1@newscl01ah.mathworks.com...
> how can i fix this error?
>
> When I give as a parameter GKN to the newff to be able use a loop
> then I receive an error message "Reference to a cleared variable" at the
> newff line by referencing to GKN value.
> How can i put this integer value to this function?
>
> GKN=75; % this value will change in every iteration by a loop

So where's the loop? Show (a little) more code!

> net=newff(minmax(INP),[GKN 64],{'tansig','logsig'},'traingdx');
>
> Anyone,can fix the error?

My guess is that you're calling CLEAR inside the loop that defines GKN and
calls NEWFF. If so, remove the CLEAR.

*snip*

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Reference to a cleared variable

From: trash

Date: 30 Jan, 2014 16:26:08

Message: 3 of 3

Thanks Steven.

> > When I give as a parameter GKN to the newff to be able use a loop
> > then I receive an error message "Reference to a cleared variable" at the
> > newff line by referencing to GKN value.
> > How can i put this integer value to this function?
> >
> > GKN=75; % this value will change in every iteration by a loop
>
> So where's the loop? Show (a little) more code!
> >
> > Anyone,can fix the error?
>
> My guess is that you're calling CLEAR inside the loop that defines GKN and
> calls NEWFF. If so, remove the CLEAR.
>
> *snip*

Tags for this Thread

No tags are associated with 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