I have a compex MATLAB simulation model of an aircraft. The simulation uses MATLAB's ode45 solver to integrate the equations of motions in time. I'm trying to implement a flight control system (FCS) in SIMULINK which will continuosly provide the required control commands to the simulation during each integration step (using the "sim" command). The only way I could achieve this is: 1. Integrate the aircraft state equations during a short time interval (say dt). 2. Call the sim command using the current aircraft states (speed, angular rates, etc…) and the last step complete SimState of the FCS, and advance the control system by this short time interval (dt), in order to produce the next time step control command to the aircraft. 3. Save a complete SimState to the workspace, which will be used during the next sim command as initial conditions. 4. Advance simulation time by dt and return to step 1.
The problem is that this technique (saving the complete SimState at the end of each time step, and reloading it prior to the next step "sim" command) is both time consuming, and prevents the use of the 'rapid' acceleration mode.
My question is: How can I run SIMULINK continuously, such that my model's internal workspace is kept between successive calls, so that I would just have to update the input ports values in between calls to the model, and continue the simulation for the next time step ? (Obviously, I would need access to the model input and output ports inorder to provide continuos input to the model, and extract the output command).
Best Answer