How to get matrices from S-function to Simulink?

4 visualizaciones (últimos 30 días)
Ahmed Elsaadany
Ahmed Elsaadany el 17 de Jul. de 2013
i made S-function that calculates the linear variant time model, which take its input from the simulink. and the output of this file is the state matrices, (A,B,C,D). but i can't get these matrices into the simulink simulation. and also if i got it, how i can get the system output from these matrices to compare between this linear model with its corresponding non-linear system. Ahmed.
  2 comentarios
Kaustubha Govind
Kaustubha Govind el 17 de Jul. de 2013
Your question is very unclear. What do you mean by "i can't get these matrices into the simulink simulation" - do you not assign them to the outputs of the S-function? If you've tried that already and failed, please specify the exact error messages that you received.
Kaustubha Govind
Kaustubha Govind el 18 de Jul. de 2013
Ahmed: Please post replies to comments here and avoid sending personal messages.
---Message from Ahmed follows---
i already assigned them to the outputs of the S-function, but maybe i had mistake. i assigned it as follow:
sys(1) = A;
sys(2) = B;
sys(3) = C;
sys(4) = D;

Iniciar sesión para comentar.

Respuestas (1)

Kaustubha Govind
Kaustubha Govind el 18 de Jul. de 2013
Firstly, it appears that you are writing a Level-1 S-function, which has been deprecated for several years now. It currently only exists for the sake of backwards compatibility. The documentation on this topic is very sparse, so I can't be of much help with them. I would recommend that you Convert your Level-1 MATLAB S-Function to Level-2 first.
You can look at example models with Level-2 S-functions to understand what you need. I recommend typing "sfundemos" at the MATLAB prompt and browse to MATLAB file S-functions -> Level-2 MATLAB file S-functions. You can start with the "Times two" example for a simple case, and then move on to the other examples.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by