#*------------------------------------------------------------------- * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. * * This LIBRARY is free software; you can distribute it and/or modify * it under the therms of the ALSOC FREE LICENSE as available at * http://www.enq.ufrgs.br/alsoc. * * EMSO is distributed under the terms of the ALSOC LICENSE as * available at http://www.enq.ufrgs.br/alsoc. *----------------------------------------------------------------------- * Author: Jonathan Ospino P. * $Id: Math_Fcns.mso 2012$ *---------------------------------------------------------------------*# using "types"; Model Math_Fcns ATTRIBUTES Pallete=true; Icon="icon/Math_Fcns"; Info="== Math functions block == It computes the functions abs(x), sign(x), ln(x), log10(x), x^N, or Nth-Root(x), where x is the input signal. The resulting value is assigned to the output variable"; PARAMETERS Select_function as Switcher(Valid=["|x|","sign(x)","e^x","ln(x)","log10(x)","x^n","Nth-Root(x)"],Default="|x|"); n as Real(Brief="Only to be used in the x^n computation",Default=2); N as positive(Brief="Only to be used in Nth-Root(x) computation",Default=2); VARIABLES in In as Real(Brief="Input signal",PosX=0,PosY=0.5); out Out as Real(Brief="Output signal",Protected=true,PosX=1,PosY=0.5); EQUATIONS switch Select_function case "|x|": Out=abs(In); case "sign(x)": Out=sign(In); case "e^x": Out=exp(In); case "ln(x)": Out=ln(In); case "log10(x)": Out=log(In); case "x^n": Out=In^n; case "Nth-Root(x)": Out=In^(1/N); end end