I understand that you are facing error while calling t
In MATLAB, when you call a method from an object, you need to accept the object itself (or a reference to the current object) as the first parameter in the method. The first parameter will always refer to the object instance, and after that, you can have your additional parameters. In other languages like C++, this is passed implicitly.
In your case, when you call this function from command = obj.commandSystem.command(t, obj.powerSystem, obj.commandSystem);, The parameters received will be as follows:
t = obj
powerSystem = t
commandSystem = obj.powerSystem
obj = obj.commandSystem
So, when this line runs ‘ disp(commandSystem.socSafe)’, it is referring to the ‘powerSystem’ object, hence the error message "Unrecognized method, property, or field 'socSafe' for class 'powerSystem'.
To fix the issue, you can define your function like the following example
function [command] = command(obj, t, powerSystem, commandSystem)
By rearranging the parameters and accepting the object as the first parameter, you can access the properties and methods of the correct objects within the method.
This change ensures that the method receives the correct object references and resolves the error you encountered.
To know more about passing object in a method, I suggest referring to the following documentation:
I hope this help you resolve the issue.
