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:
problem with clearing classes

Subject: problem with clearing classes

From: Yuri Geshelin

Date: 2 Jan, 2009 14:29:01

Message: 1 of 3

I have a simple function that defines a class:

function output_arg = myclass06( i )
superiorto('myclass07')
b.k6 = i + 6;
output_arg = class(b,'myclass06');
%%% end of myclass06

I call it this way:

>> m6 = myclass06(1);

and it works. Next, I execute the CLEAR command:

>> clear classes

and replace SUPERIORTO with INFERIORTO. I then try to call myclass06 again, but here is what happens:

>> m6 = myclass06(1);
??? Error using ==> inferiorto
The precedence between class myclass06 and myclass07 cannot be changed without clear classes.

Error in ==> myclass06.myclass06 at 3
inferiorto('myclass07')
..........

But I did clear classes, so why didn't CLEAR CLASSES work? I know it works when I change the number of fields in the class, so what is wrong with SUPERIORTO / INFERIORTO? Surely I don't have to restart matlab to circumvent this?

Subject: problem with clearing classes

From: Steven Lord

Date: 2 Jan, 2009 18:06:26

Message: 2 of 3


"Yuri Geshelin" <geshelin@hotmail.com> wrote in message
news:gjl8bd$gjc$1@fred.mathworks.com...
>I have a simple function that defines a class:
>
> function output_arg = myclass06( i )
> superiorto('myclass07')
> b.k6 = i + 6;
> output_arg = class(b,'myclass06');
> %%% end of myclass06
>
> I call it this way:
>
>>> m6 = myclass06(1);
>
> and it works. Next, I execute the CLEAR command:
>
>>> clear classes
>
> and replace SUPERIORTO with INFERIORTO. I then try to call myclass06
> again, but here is what happens:
>
>>> m6 = myclass06(1);
> ??? Error using ==> inferiorto
> The precedence between class myclass06 and myclass07 cannot be changed
> without clear classes.

The old m6 variable still existed when you executed this command, right? If
so, if I remember correctly the previous CLEAR CLASSES call couldn't clear
myclass06 out of memory (since an instance of the class existed) and so you
receive this error when you try to use the new class definition.

Clear the first m6 variable, then CLEAR CLASSES, and the second
instantiation should work.

--
Steve Lord
slord@mathworks.com

Subject: problem with clearing classes

From: Yuri Geshelin

Date: 2 Jan, 2009 19:58:01

Message: 3 of 3

"Steven Lord" <slord@mathworks.com> wrote in message <gjll32$lar$1@fred.mathworks.com>...
 
> The old m6 variable still existed when you executed this command, right? If
> so, if I remember correctly the previous CLEAR CLASSES call couldn't clear
> myclass06 out of memory (since an instance of the class existed) and so you
> receive this error when you try to use the new class definition.
>
> Clear the first m6 variable, then CLEAR CLASSES, and the second
> instantiation should work.
>
> --
> Steve Lord
> slord@mathworks.com
>

Thanks Steve,

No, it did not help. I checked it on another machine: the same thing.

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