[944] | 1 | #*------------------------------------------------------------------- |
---|
| 2 | * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. |
---|
| 3 | * |
---|
| 4 | * This LIBRARY is free software; you can distribute it and/or modify |
---|
| 5 | * it under the therms of the ALSOC FREE LICENSE as available at |
---|
| 6 | * http://www.enq.ufrgs.br/alsoc. |
---|
| 7 | * |
---|
| 8 | * EMSO is distributed under the terms of the ALSOC LICENSE as |
---|
| 9 | * available at http://www.enq.ufrgs.br/alsoc. |
---|
| 10 | *----------------------------------------------------------------------- |
---|
| 11 | * Author: Jonathan Ospino P. |
---|
| 12 | * $Id: Math_Fcns.mso 2012$ |
---|
| 13 | *---------------------------------------------------------------------*# |
---|
| 14 | |
---|
| 15 | using "types"; |
---|
| 16 | |
---|
| 17 | Model Math_Fcns |
---|
| 18 | |
---|
| 19 | ATTRIBUTES |
---|
| 20 | Pallete=true; |
---|
| 21 | Icon="icon/Math_Fcns"; |
---|
| 22 | Info="== Math functions block == |
---|
| 23 | |
---|
| 24 | It computes the functions abs(x), sign(x), ln(x), log10(x), x^N, or Nth-Root(x), |
---|
| 25 | where x is the input signal. |
---|
| 26 | The resulting value is assigned to the output variable"; |
---|
| 27 | |
---|
| 28 | PARAMETERS |
---|
| 29 | Select_function as Switcher(Valid=["|x|","sign(x)","e^x","ln(x)","log10(x)","x^n","Nth-Root(x)"],Default="|x|"); |
---|
| 30 | n as Real(Brief="Only to be used in the x^n computation",Default=2); |
---|
| 31 | N as positive(Brief="Only to be used in Nth-Root(x) computation",Default=2); |
---|
| 32 | |
---|
| 33 | VARIABLES |
---|
| 34 | in In as Real(Brief="Input signal",PosX=0,PosY=0.5); |
---|
| 35 | out Out as Real(Brief="Output signal",Protected=true,PosX=1,PosY=0.5); |
---|
| 36 | |
---|
| 37 | EQUATIONS |
---|
| 38 | |
---|
| 39 | switch Select_function |
---|
| 40 | case "|x|": |
---|
| 41 | Out=abs(In); |
---|
| 42 | case "sign(x)": |
---|
| 43 | Out=sign(In); |
---|
| 44 | case "e^x": |
---|
| 45 | Out=exp(In); |
---|
| 46 | case "ln(x)": |
---|
| 47 | Out=ln(In); |
---|
| 48 | case "log10(x)": |
---|
| 49 | Out=log(In); |
---|
| 50 | case "x^n": |
---|
| 51 | Out=In^n; |
---|
| 52 | case "Nth-Root(x)": |
---|
| 53 | Out=In^(1/N); |
---|
| 54 | end |
---|
| 55 | |
---|
| 56 | end |
---|