Calling a class method from a GUI
Show older comments
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 Comment
snow John
on 2 Sep 2019
Hello sir,
I have met the same problem ,can you give me some cases as reference.
Your help will be appreciated.
Bset!
-John
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!