Hi Marc,
From what I can gather, you are trying to call a callback function from classB which is a public function defined in classA.
The format to call a function present in a class is:
[object of the class].[name of the function]
Here’s an example on how you can declare the public function from classA into the parameters of classB:
(classA)
classdef classA
methods (Access = public)
function obj = classA()
disp("Constructor class A");
end
function sampleCallBack(obj)
disp("This is a sample callback message");
end
end
end
(classB)
classdef classB
methods(Access = public)
function obj = classB(callback)
callback();
disp("Constructor class B")
end
end
end
As shown in above example, we were able to call a public method in classA from classB.
“When readback obj.CallBack_Fcn = @MyCallback; - there is no reference to the class which passed it”
To access a property or a method from a class, you need to use class objects in MATLAB. Without a class object MATLAB wouldn’t know which [class and method] you are trying to use.
You can learn more about calling a function defined in a class using the following stack overflow thread:
I hope this helps, thanks!