MATLAB: How to replace a direct connection with a sensor-actuator pair in Simscape


Starting from an example model, I am trying to disconnect one of the elements from the rest of the model.
For now I am trying to achieve this by using two pairs of sensors and actuators, such that the sensors measure the <THROUGH-VARIABLE> applied at each of the connection ends, which is then 'sent' to the actuators to act on the opposite port.
However, I am running into the following error:
An error occurred while running the simulation and the simulation was terminated
How can I fix this?

Best Answer

  • The correct way to break a complete Simscape network into two separate ones is to measure the both the <THROUGH-VARIABLE> and <ACROSS-VARIABLE> and feed these measurements into two networks using the ideal source and ideal source blocks.
    In the case of a rotational mechanics example, the following image shows how this can be achieved when the <THROUGH-VARIABLE> and <ACROSS-VARIABLE> are torque and rotational velocity, respectively:
    This setup will result in the same behavior as if you were to connect points A and B directly.