Hi everyone,
I am using an level II S-Function to send the position of a robot from Simulink to the MATLAB workspace. In the workspace, a controller computes the appropriate control commands and sends them back to Simulink via another Level-2 S-Function.
In the second S-Function, which is responsible for sending the computed control commands from the workspace to Simulink, I have defined two output ports and zero input ports. However, the Simulink block shows a single input port (due to the argument block) and no output ports.
Can someone explain what I should do to make the output ports visible?
I enclosed the picture of the block in Simulink.
(I am using 2019b release)
Thanks in advance
Here is my code for the second Level-2 S-Function:
function getThrust(block)
block.OutputPort(1).Dimensions = 4;
block.OutputPort(2).Dimensions = 4;
block.OutputPort(1).Complexity = 'Real';
block.OutputPort(2).Complexity = 'Real';
block.OutputPort(1).DatatypeID = 0;
block.OutputPort(2).DatatypeID = 0;
block.SampleTimes = [0.1 0];
block.RegBlockMethod('Outputs',@Outputs);
RPM_in = evalin('base', 'thrusterPower');
alpha_in = evalin('base', 'thrusterAngles')
RPM_in = reshape(RPM_in, [1,4]);
alpha_in = reshape(alpha_in, [1,4]);
block.OutputPort(1).Data = RPM_in;
block.OutputPort(2).Data = alpha_in;