As a simple example, I would like to implement a Kalman-Filter in a level 2 m-file s-function. Because of this, I need a covariance matrix P, which will be updated at every time step (so, the matrix of the last timestep is also needed). It would be self-evident to use a DWork variable for this. But the DWork variable cannot be defined as a matrix. Do you have any ideas how a matrix can be implemented in a s-function as a DWork-like structure?