Controlling output from Simulink

3 visualizaciones (últimos 30 días)
Tan Edwin
Tan Edwin el 8 de Mzo. de 2011
Hi all
My simulink is running at a fixed time step of 0.1 and i need my block to produce output at alternate time like 0,0.2,0.4,etc
Can GetTimeOfNextVarHit of lvl 1 S-function block fulfil this requirement?
If not how should i do it?
  1 comentario
Tan Edwin
Tan Edwin el 8 de Mzo. de 2011
just tested GetTimeOfNextVarHit, it seems to only give me a transport delay?

Iniciar sesión para comentar.

Respuestas (3)

Kaustubha Govind
Kaustubha Govind el 8 de Mzo. de 2011
Why not set the S-function sample time to 2*ssGetFixedStepSize(S) in mdlInitializeSampleTimes? You might also want to protect your code using ssIsVariableStepSolver to ensure that a variable-step solver isn't being used.
  2 comentarios
Tan Edwin
Tan Edwin el 9 de Mzo. de 2011
wat is the equivalence of ssGetFixedStepSize in m programming language? cos im not trained in C, C++ programming.
and it is a lvl 2 s-function right?
thanks
Kaustubha Govind
Kaustubha Govind el 11 de Mzo. de 2011
Try str2num(get_param(bdroot,'FixedStep'))

Iniciar sesión para comentar.


Andreas Goser
Andreas Goser el 8 de Mzo. de 2011
Check out the menu:
Simulation -> Configuration Parameters -> Data Import/Export
In your example, you could just enter a decimation of 2. But you have also other option, see the pull-down "Output options". You can e.g. produce additional output.
  1 comentario
Tan Edwin
Tan Edwin el 8 de Mzo. de 2011
i actually have other blocks in my .mdl that need to run at the fixed time of 0.1 so wouldnt this method affect all the other blocks?
i just need the one block to run at alternate time and the rest at normal time.
Thanks for the suggestion and so sorry that i didn't make myself clear earlier.

Iniciar sesión para comentar.


Paulo Silva
Paulo Silva el 8 de Mzo. de 2011
Try with the matlab Fcn block
out=u(1) %or out=u
It will put the value in the block input to the variable out in the matlab workspace, that way you can share data with other models, do the same thing to get data from the workspace
out %the value of out will be the output of the Fcn block
And maybe putting 0.2 on the matlab Fcn sample time will only update or get the out value each 0.2 seconds.
  2 comentarios
Tan Edwin
Tan Edwin el 8 de Mzo. de 2011
what do you mean by "matlab workspace"? is it the main workspace where the mat files are saved?
Paulo Silva
Paulo Silva el 8 de Mzo. de 2011
the code that you put in your matlab fcn block are just like the ones you execute in the command line, same memory area.

Iniciar sesión para comentar.

Categorías

Más información sobre Block Authoring Basics 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