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!