using self created class in gui
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Sean de Wolski
2012-3-9
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
2012-3-9
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!