EdibleRobot
EdibleRobot

Reputation: 1

Simout output from sim command called from Matlab Function Block in Simulink

I'm trying to simulate a model "inner.mdl" (several timesteps) in one timestep of the root model "outer.mdl". I thought of calling simout = sim("inner.mdl") from a Matlab Function Block. The problem is: Since I'm using extrinsic sim (bypassing code generation), simout is returned as an MxArray and I am unable to retrieve the logged signals from it. Any ideas would be appreciated, whether they are about doing this simulation-in-simulation or with obtaining the logged signals using the method I'm trying.

The main reason I'm doing this is that as part of a controller, I'm trying to simulate the system a few steps ahead in the future to use that information in some way. I don't want to turn my controller into code and even if I get rid of the simulation-time dependent blocks, I don't know how to run a block for some timesteps without the whole model moving forward in time.

Upvotes: 0

Views: 1320

Answers (1)

am304
am304

Reputation: 13876

Normally, if you initialise a variable to 0 or equivalent before having an extrinsic function call that returns this variable, the variable will be of type double rather than MxArray. Not sure if this works for simout though, as I seem to remember that simout is a structure. Still worth a try.

See Working with mxArrays in the documentation for more details.

Upvotes: 1

Related Questions