How to get matrices from S-function to Simulink?

5 views (last 30 days)
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 Comments
Kaustubha Govind
Kaustubha Govind on 17 Jul 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 on 18 Jul 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;

Sign in to comment.

Answers (1)

Kaustubha Govind
Kaustubha Govind on 18 Jul 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.

Tags

Products

Community Treasure Hunt

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

Start Hunting!