Borrar filtros
Borrar filtros

"Matlab Function" calling sequence in Simulink

1 visualización (últimos 30 días)
Pedro Pérez de Ayala Rull
Pedro Pérez de Ayala Rull el 16 de Jun. de 2016
Comentada: Pedro Pérez de Ayala Rull el 22 de Jun. de 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

Respuestas (1)

Debarati Banerjee
Debarati Banerjee el 22 de Jun. de 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
  1 comentario
Pedro Pérez de Ayala Rull
Pedro Pérez de Ayala Rull el 22 de Jun. de 2016
Thanks for your answer Debarati. I'm out of office for the next two weeks, I'll give it a try when I'm back and let you know the results.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by