using self created class in gui
조회 수: 2 (최근 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에서 Construct and Work with Object Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!