Thread Subject: Class m-file editing problems

Subject: Class m-file editing problems

From: Pj

Date: 11 Mar, 2009 10:23:01

Message: 1 of 5

I have been developing a class which as part of its function creates a GUI. I was recently adding some uicontrol objects to this GUI using my usual trial and error approach. In one instance I created a uicontrol object and a callback function within the method block of the class but I failed to assign enough input arguments to the callback function. Obviously when I ran the program it returned an 'Too many inputs error'. I duly updated the callback function to take the second callback argument. I then saved the class m-file and cleared the current object of that class in the workspace and closed (using the window close button - bad I know) the GUI figure window.

On recreating an object of the class the error persisted (I assume the old class definition was still being used) until I closed and reopened MATLAB. Question is: why did the class not update? I'm guessing because I used the window close button on the GUI figure which allowed an object to persist in the workspace? But this is a guess and an authoritative answer from someone who knows better would be welcome - I'm quite new to OO in MATLAB.

Many thanks,

P

Subject: Class m-file editing problems

From: John D'Errico

Date: 11 Mar, 2009 11:39:01

Message: 2 of 5

"Pj " <northern69@yahoo.com> wrote in message <gp83e5$n4s$1@fred.mathworks.com>...
> I have been developing a class which as part of its function creates a GUI. I was recently adding some uicontrol objects to this GUI using my usual trial and error approach. In one instance I created a uicontrol object and a callback function within the method block of the class but I failed to assign enough input arguments to the callback function. Obviously when I ran the program it returned an 'Too many inputs error'. I duly updated the callback function to take the second callback argument. I then saved the class m-file and cleared the current object of that class in the workspace and closed (using the window close button - bad I know) the GUI figure window.
>
> On recreating an object of the class the error persisted (I assume the old class definition was still being used) until I closed and reopened MATLAB. Question is: why did the class not update? I'm guessing because I used the window close button on the GUI figure which allowed an object to persist in the workspace? But this is a guess and an authoritative answer from someone who knows better would be welcome - I'm quite new to OO in MATLAB.
>
> Many thanks,
>
> P

Usually the reason for m-files not updating is you
have put them in the wrong directory. Those
files put in the matlab toolbox directories should
not have been. They will not be updated. Use
your own directories for custom functions, and
put them on the search path.

Regardless, issuing a

  clear functions

should have resolved your problem.

John

Subject: Class m-file editing problems

From: Bruno Luong

Date: 11 Mar, 2009 12:11:02

Message: 3 of 5

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gp87sl$auj$1@fred.mathworks.com>...

> Regardless, issuing a
>
> clear functions
>

Or alternatively REHASH

Bruno

Subject: Class m-file editing problems

From: Pj

Date: 11 Mar, 2009 12:54:01

Message: 4 of 5

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gp87sl$auj$1@fred.mathworks.com>...
> "Pj " <northern69@yahoo.com> wrote in message <gp83e5$n4s$1@fred.mathworks.com>...
> > I have been developing a class which as part of its function creates a GUI. I was recently adding some uicontrol objects to this GUI using my usual trial and error approach. In one instance I created a uicontrol object and a callback function within the method block of the class but I failed to assign enough input arguments to the callback function. Obviously when I ran the program it returned an 'Too many inputs error'. I duly updated the callback function to take the second callback argument. I then saved the class m-file and cleared the current object of that class in the workspace and closed (using the window close button - bad I know) the GUI figure window.
> >
> > On recreating an object of the class the error persisted (I assume the old class definition was still being used) until I closed and reopened MATLAB. Question is: why did the class not update? I'm guessing because I used the window close button on the GUI figure which allowed an object to persist in the workspace? But this is a guess and an authoritative answer from someone who knows better would be welcome - I'm quite new to OO in MATLAB.
> >
> > Many thanks,
> >
> > P
>
> Usually the reason for m-files not updating is you
> have put them in the wrong directory. Those
> files put in the matlab toolbox directories should
> not have been. They will not be updated. Use
> your own directories for custom functions, and
> put them on the search path.
>
> Regardless, issuing a
>
> clear functions
>
> should have resolved your problem.
>
> John

To clarify, all class definitions are saved in project specific directories and not in toolbox directories. However, you have probably hit the nail on the head with clear functions. I was only clearing the workspace variables.

Thanks,

P

Subject: Class m-file editing problems

From: Titus

Date: 11 Mar, 2009 13:08:05

Message: 5 of 5


"Pj " <northern69@yahoo.com> schrieb im Newsbeitrag
news:gp8c99$op$1@fred.mathworks.com...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in message
> <gp87sl$auj$1@fred.mathworks.com>...
>> "Pj " <northern69@yahoo.com> wrote in message
>> <gp83e5$n4s$1@fred.mathworks.com>...
>> > I have been developing a class which as part of its function creates a
>> > GUI. I was recently adding some uicontrol objects to this GUI using my
>> > usual trial and error approach. In one instance I created a uicontrol
>> > object and a callback function within the method block of the class but
>> > I failed to assign enough input arguments to the callback function.
>> > Obviously when I ran the program it returned an 'Too many inputs
>> > error'. I duly updated the callback function to take the second
>> > callback argument. I then saved the class m-file and cleared the
>> > current object of that class in the workspace and closed (using the
>> > window close button - bad I know) the GUI figure window.
>> >
>> > On recreating an object of the class the error persisted (I assume the
>> > old class definition was still being used) until I closed and reopened
>> > MATLAB. Question is: why did the class not update? I'm guessing because
>> > I used the window close button on the GUI figure which allowed an
>> > object to persist in the workspace? But this is a guess and an
>> > authoritative answer from someone who knows better would be welcome -
>> > I'm quite new to OO in MATLAB.
>> >
>> > Many thanks,
>> >
>> > P
>>
>> Usually the reason for m-files not updating is you
>> have put them in the wrong directory. Those
>> files put in the matlab toolbox directories should
>> not have been. They will not be updated. Use
>> your own directories for custom functions, and
>> put them on the search path.
>>
>> Regardless, issuing a
>>
>> clear functions
>>
>> should have resolved your problem.
>>
>> John
>
> To clarify, all class definitions are saved in project specific
> directories and not in toolbox directories. However, you have probably hit
> the nail on the head with clear functions. I was only clearing the
> workspace variables.
>
> Thanks,
>
> P

Hi,
in fact, the
clear classes
is the appropriate command (BTW, you should have gotten a warning saying
something like "objects of class foo still exist, using old class definition
although m-file has changed")

Titus

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
class Phil 11 Mar, 2009 06:25:07
objects Phil 11 Mar, 2009 06:25:07
rssFeed for this Thread

Contact us at files@mathworks.com