S functions writen in C and Simulink

I'm simulating a process by using S-functions written in C in Simulink. I know my code is ok because the final result and control is working well, but I have a problem in monitoring middle stage variables. I wrote a S-function (level 1) in C with 5 outputs. Then I plot (using scopes) and store that data to the workspace. However, for some strange reason the output number 4 is always zero and output number 5 looks like the number 4 should be. I review my code but everything seems to be right. Then I reduce the number of outputs to 4 and I assigned the previous 4 and 5 outputs as 1 and 2. The outputs were ok in this case. It just confirmed me it is not a problem regarding my code. Does anybody have an idea about this problem?? Maybe is there a limit to the number of outputs in functions written in C??
and solving this problem by reassigning the outputs each time is not a viable solution since I have to run this code a lot of times and by doing that I should have to spend a lot of time by running twice each one.

1 Comment

Perhaps you have not configured the number of outputs and the properties of ports 4 and 5 correctly? Could you paste the relevant code?

Answers (0)

This question is closed.

Asked:

on 10 Jun 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!