Calling a class method from a GUI
이전 댓글 표시
Hello there?
I am making a OOP test program that we can run at a GUI. The code for the class is
classdef test_1 < handle
properties
name
connectStatus = 0
end
methods
% Constructor
function obj = test_1(test_name)
obj.name = test_name
end
function status = getStatus(obj)
status = obj.connectStatus
end
function obj = setStatus(obj, newStatus)
obj.connectStatus = newStatus
end
end
end
When I run this on workspace, I found that it works fine. I can check the values of the attributes of the object and I can run the method suich as getStatus, setStatus.
Now I made a GUI and tried to run the method whenever I push a button on the GUI. But Matlab gives me error messages like
'Undefined variable "obj" or class "obj.getStatus"'.
Here, obj is the object that I created and getStatus is the method.
I think the problem is simple but I do not know how to solve this.
So, I will be very thankful if someone give me a tip.
Thanks.
댓글 수: 1
snow John
2019년 9월 2일
Hello sir,
I have met the same problem ,can you give me some cases as reference.
Your help will be appreciated.
Bset!
-John
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!