S-Function Level 1 vs S-Function Level 2
37 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a problem. I have modeled a dynamic system( 5 inputs and 10 outputs) using S-Function Level-1 and Level-2. Both models work very well. My question is: Why the model that uses S-Function Level-2 runs its simulation very slowly? With the level 1 model simulation is very fast.
1 Kommentar
want2know
am 15 Jul. 2013
Dear Miguel,
I have read your post and I understand that you have successfully developed your system in S-function level 1.
Do you mind to spend a couples of minutes to read the following: please
I have been using S-function to do the following:
[a1, b1] = choose_cells(c, d);
where a1 and b1 are outputs, c and d are inputs. All the variables are having a single value, except d is an array with 6 values.
Referring to the image attached, we all know that in S-function block, the input dimension must be SAME as output dimension, else we will get error, in this case, the input dimension is 7 while the output dimension is 2, so I have to include the "Terminator" blocks in the diagram for it to work perfectly, otherwise, I will get an error.
My problem is, when the system gets bigger, the array d could contain hundreds of variables, using this method, it means I would have to add hundreds of "Terminator" blocks in order to get this work, this definitely does not sound practical.
Could you please suggest me a wise way to implement this?
Thanks in advance.
Antworten (4)
Kaustubha Govind
am 22 Mär. 2012
I don't have a definite answer, and it's difficult to say not having seen your code, but it could be because Level-2 S-functions have a lot more features than Level-1 S-functions, so there is probably a lot of heavy-lifting/back-end work done by them? Exactly how slow are we talking about? Can you provide a ratio?
Ben
am 23 Mär. 2012
Profile your code but ticking the 'profile' entry in the Simulink tools menu.
You will probably see that the Level-2 function has its state functions called several thousand times more often than the Level-1 one does (for example my Level-1 function has its output function called ~6000 times, the Level-2 output function is called ~450,000 times!). This is the source of the slow-down, but I don't know how to fix it, sorry. Trying to work that out myself now!
0 Kommentare
Ben
am 23 Mär. 2012
Solved it for my particular simulation: I had direct feedthrough incorrectly enabled for an input port. This created an agebraic loop.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Simulink Functions finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!