So I have a Quadcopter model which follows a given path. In the control loop for this quadcopter i have a matlab function block which is suppose to run a simulation of quadcopter to simulate the next 2 seconds of flight, given the current state and return some data from this simulation to be used in the control loop output. The problem i was having was that I cant seem to get any data into the parent workspace to use in the control loop. I was able to map the state to the subsimulation but I had to declare the 'run' and 'sim' commands as coder.extrinsic for them to run else I get code generation errors. As far as my understanding goes once they are declared extrinsic Matlab doesnt allow you to return data from the simulation by definition.
My question is basically how do I get data from a simulation after declaring the sim and run commands extrinsic? I have tried to use Data stores and setting return data in the simulation configuration but nothing worked so far. Sorry if the post is not clear, first time posting in a forum.
Best Answer