i am trying to use mathematical function, particularly ‘mod’ in system modeler. i want to find remainder of some continuous stream and pass it on for further processing. please suggest. i am new to modeler and i am sure i am missing some simple thing
in SystemModeler just you would use Mod[x,y] in Mathematica and get the integer modulus of x/y. Note that if either of the arguments are Real the results is Real otherwise Integer. mod() will trigger state events when used outside of a when-clause, these are triggered when the return value changes discontinuously.
i tried writing the code as attached in the file. it is giving error. can you please suggest as i think it is syntactical error for not able to call mathematica functions. for simplicityr sake it is also copied below
block my_mod1 “find remainder after division”
Modelica.Blocks.Interfaces.RealInput u “input signal connector”
Modelica.Blocks.Interfaces.RealOutput y “output signal connector”
i tried writing the code as attached in the file. it is giving error. can you please suggest as i think it is syntactical error for not able to call mathematica functions. for simplicity sake it is also copied below
block my_mod1 “find remainder after division”
Modelica.Blocks.Interfaces.RealInput u “input signal connector”
Modelica.Blocks.Interfaces.RealOutput y “output signal connector”
equation y = Mod[u,360]
end my_mod1;
In SystemModeler the functions have lowercase names, and you use () instead of [], below is a modified version of your code that should do the trick:
block my_mod1 "find remainder after division"
Modelica.Blocks.Interfaces.RealInput u "input signal connector" ;
Modelica.Blocks.Interfaces.RealOutput y "output signal connector" ;
equation
y = mod(u, 360);
end my_mod1;