"Matlab Function" calling sequence in Simulink
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Pedro Pérez de Ayala Rull
am 16 Jun. 2016
Kommentiert: Pedro Pérez de Ayala Rull
am 22 Jun. 2016
Hi all,
I'm having a problem with a "Matlab function" block. The issue is that the function is written assuming that it will always be passed new data.
The function is a simple frequency estimator, which looks for zero crossings of the input signal and everytime it detects a new zero crossing, outputs the new frequency value based on the time between crossings.
The problem I'm having is that suddenly, it is outputting a very high frequency because it is getting several zero crossings in close proximity. The input to this function comes from a sine block, so there is no noise.
I have been logging the arguments passed to the function (sine wave value and time), and I have seen that the function is not always called with increasing time values. Sometimes it's called with the same time value twice or more, and sometimes it even receives past values.
I think this could have something to do with the solver going back and forth to find some zero crossing or something, but I haven't found any documentation describing this behavior and possible workarounds.
Thanks, Pedro
0 Kommentare
Antworten (1)
Debarati Banerjee
am 22 Jun. 2016
I guess you are using 'Variable-Step Solver' for which you are seeing that sometimes its on the same Time values and sometimes it gets past values. You can get more information on this topic in this blog
Can you use Fixed Step solver for your case with a suitable Sample time (such that the Zero Crossings are not missed)?
Cheers, Debarati
Siehe auch
Kategorien
Mehr zu Install Products finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!