using self created class in gui
1 view (last 30 days)
Show older comments
hi, im trying to understand the the oop concept in matlab. i got some classes
classdef myclass
...
end
without gui i could write
blabla = myclass
but i want to create an instance of a class when a button is clicked. so in that case i dont have a name for that instance or object. how is that generally done in matlab
thanx a lot
0 Comments
Answers (2)
Sean de Wolski
on 9 Mar 2012
Well, what do you want to name it? And what do you want to do with it after? You could have an edit box in the gui qwhere the user puts in the name they want to call it. etc. This is a hard question to answer without more detail.
Walter Roberson
on 9 Mar 2012
You would still write
blabla = myclass
in your callback of the button. That will create the instance within the workspace of the callback function.
The problem then shifts to how you avoid having the instance destroyed when the callback function returns. The answers to that are much like if it was a numeric value you had computed: store the object somewhere that will continue to exist once the callback function returns.
0 Comments
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!