Message Boards Message Boards

0
|
5637 Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

how to use mathematical functions in system modeler

Posted 11 years ago

hi friends

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

POSTED BY: manu gaurav
5 Replies

thankyou for not only solving my problem but a better guidance as well.

can you solve my problem on how to use combiTable1D in system modeler also. i have written with details in my posts

POSTED BY: manu gaurav

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;
POSTED BY: Mikael Forsgren

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;

POSTED BY: manu gaurav

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"

equation y = Mod[u,360]

end my_mod1;

Attachments:
POSTED BY: manu gaurav

Hi!

you can use

  mod(x,y)

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.

POSTED BY: Mikael Forsgren
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract