The second s-function only run at first step in multiple S-Functions cases

조회 수: 2 (최근 30일)
I am running a simulink model with 2 S-functions (more in the future), while it cannot gives a correct result. When using some printf in my codes, I found that the second s-function runs only at the first step, although the first s-function runs continuously each step. What makes me confused is that when run the two S-function separately, by using workspace for data transmission indirectly, it works. Thus, I think there should be some tricks about running a model where the s-function cooperating with each other. Could someone give me some hints about it?
In the attachment is my model with the two C-codes.
My problem is that my simulink model can only support one s-function running continuously with fixed step (0.001s). When connecting s-function to another, the second s-function runs only at the first step.
Thank you for your reading

채택된 답변

Yixiao Wang
Yixiao Wang 2016년 9월 25일
Now I solved this problem Take care of the sample time setting when you connect the separate s-function blocks!
if true
ssSetNumSampleTimes(S, 1);
end
I changed the value to -1 then it works.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by