Home > mpt > extras > auxiliary > di_sim_fun.m

di_sim_fun

PURPOSE ^

DI_SIM_FUN Example of a function to model arbitrary dynamics

SYNOPSIS ^

function [xnext, yk] = di_sim_fun(xk, uk)

DESCRIPTION ^

 DI_SIM_FUN Example of a function to model arbitrary dynamics

 If you want to use the sim() or simplot() functions to simulate controllers
 with different dynamical systems than those which have been used to compute
 the controller, you can do so by providing a handle to a special simulation
 function when calling sim() or simplot(), e.g.:

   sim(ctrl, @di_sim_fun, x0)

 The function handle must point to a function which takes exactly two inputs
 and produces exactly two outputs. The first input is always the state at time
 "k" (xk) and input at time "k" (uk). First output argument must be the next
 state update (xnext) and output associated to state xk (yk). For example:

     function [xnext, yk] = your_sim_fun(xk, uk)

     A = [1 1; 0 1]; B = [1; 0.5]; C = [1 0];
     xnext = A*xk + B*uk;
     yk    = C*xk;

 You can use arbitrary dynamics, i.e. also non-linear functions.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Thu 30-Mar-2006 10:26:47 by m2html © 2003