model a discrete system without using mdlupdate routine

1 visualización (últimos 30 días)
grapevine
grapevine el 22 de Feb. de 2012
Editada: Cedric el 21 de Oct. de 2013
Hello,
Is there a way to write a S-Function describing a discrete system with memory (e.g 1/z), without using the mdlUpdate routine to update the value of the discrete states
thanks in advance

Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 22 de Feb. de 2012
Writing a mdlUpdate is the correct way to do this. Is there a reason you want to avoid that?
You could of course get around this by combining the mdlUpdate code at the end of the mdlOutput function. For example, if u=input, x=state and y=output, your mdlOutput should look like this:
y = x;
x = u;
This is okay as long as your DirectFeedthrough is still set to true (if you set it to false, then it is not allowed to access your inputs from the output function). Setting DirectFeedthrough=true is okay if you don't plan to use your S-function block in a feedback loop that causes algebraic loops.
  2 comentarios
grapevine
grapevine el 23 de Feb. de 2012
Thank a lot
I thought about this solution, but I didn't know about the DirectFeedthrough parameter, it's in mdlInitializeSize routine, isn't it?
I totally agree with your option, it's better to use mdlupdate, but we got some problem when we used the Real time workshop.
In the opinion of my colleague RTW doesn't like the mdlupdate routine, and it usually makes some weird. I am not able to give more details about it, 'cause I don't know them, my colleague just told we should avoid to use, so .....
by the way thanks again
Kaustubha Govind
Kaustubha Govind el 23 de Feb. de 2012
Yes, the DirectFeedthrough flag is set in mdlInitializeSizes. I *think* the default may be true.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Event Functions 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