Vous êtes sur la page 1sur 18

Instrumentao e Controlo de Processos

Scilab
Noes Introdutrias
26 e 27 de Fevereiro de 2013

Mrio Eusbio (2013)

Scilab

Toda a informao gravada na rea local ser apagada aps logout Gravar toda a informao numa pen ou na net Scilab um pacote de software idntico ao Matlab e ao Octave Scilab ser usado como linguagem de suporte para ICP

Mrio Eusbio (2013)

Scilab

Mrio Eusbio (2013)

Scilab Built-in functions

sin(), cos(), tan(), cotg() asin(), acos(), atan() sinh(), cosh(), tanh(), coth() asinh(), acosh(), atanh() sqrt(), exp() sum() min(), max() abs(), sign() real(f), imag(f)

Trigonometric functions, e.g. sin(.2*%pi) Arc functions Hyperbolic functions Inverse hyperbolic functions Square root, e.g. sqrt(2) / exponent Sum Minimum / maximum value Absolute value, e.g. abs(sinc(x)) / sign Real & imaginary parts of a complex f

Mrio Eusbio (2013)

Scilab predefined variables and constants

%i %pi %e %eps %inf %nan %s %z %t, %T %f, %F

i = -1 = 3.1415927. e = 2.7182818. = 2.22 10-16

Imaginary unit Pi Napiers constant e Precision (machine dependent) Infinite (not mathematically infinite) Not a Number

s z true false

Polynomial variable Polynomial variable Boolean variable Boolean variable

Mrio Eusbio (2013)

Scilab operators ; , ' .' [] , [] ' () +, * , .* End of expression, row separator Instruction, argument or column separator Conjugate (matrix) transpose, string delimiter* Non-conjugate transpose Vector or matrix definition concatenation, transposed matrix The pair of left/ right parenthesis is used for various purposes Addition, subtraction Multiplication, element-by-element multiplication

*) Both simple (') and double (") quotes are allowed to define character strings

Mrio Eusbio (2013)

Scilab operators / , ./ \ , .\ ^ or ** , .^ .*. ./. , .\. | & ~ ==, >=, <=, >, <, < >, ~= Right division, element-by-element right division Left division, element-by element left division Power (exponent), element-by-element power Kronecker product Kronecker right and left division Logical OR Logical AND Logical NOT Equal to, equal or greater than, equal or less than, greater than, less than, not equal to (two alternatives)

Mrio Eusbio (2013)

Scilab Basic commands

who : list of variables browsevar Variable name: to see the contents of the variable pwd: shows working directory cd: changes the working directory mkdir: creates a new directory F1 // Help F2 // clears console

Mrio Eusbio (2013)

Scilab - demo a=2e-2 b=3e-5; 2+3*sin(%pi/4) c=a*b c=a*b; c^2 cos(c) x=cos(c); y=sin(c); x^2+y^2 %pi %i %e %eps (corresponds to the maximum value for which 1+%eps=1) %inf (infinity) %nan (not-a-number) test=%nan; isnan(test); (also isinf) %t (bolean True) %f (bolean False) a=3; // a=5 coments %s

Mrio Eusbio (2013)

Scilab - demo a=12 // real constant b=2>1 // bolean constant (i.e., logical) c=Instrumentao e controlo de processos // character string den=[1 2 3]; // row vector den // transpose: column vector r=poly(1.,x,roots) //polynomial with variable x and root 1.0 r=poly(1.,x,r) //polynomial with variable x and root 1.0 t=poly([1 2 3 4 5 6],'x',"coeff") // default value is roots t=poly([1 2 3 4 5 6],'x',c) // default value is roots s=poly([1 2 3],x) //polynomial with variable x and root 1.0, 2.0, 3.0 s=poly(den,x) //polynomial with variable x and root 1.0, 2.0, 3.0 u=(1+2*%s-5*%s^2+6*%s^3) q=r/s // rational expression roots(t) horner(u,1) //evaluates the polynomial u when the variable is replaced by 1

Mrio Eusbio (2013)

Scilab - demo a=1:4 // row vector with elememts from 1 to 4 b=1:0.1:4 // row vector with elememts from 1 to 4 with 0.1 space interval A=diag([1 2 3]) X=rand(3,3); A=inv(X)*A*X spec(A) // The eigenvalues of A ieee(0) // normal ieee(2) //1/0 = Inf and 0/0 = nan help poly

quit // quits scilab exit // exits scilab x=poly(0,x) y=x-1 p=-1+2*x+3*x^2 q=2-3*x+x^2 r=(p+q)/(p*q)

Mrio Eusbio (2013)

Scilab - demo // computer precision a=1-5*0.2 // gives correct answer 0. b=1-.2-.2-.2-.2-.2 //gives 5.551D-17 %eps // gives 2.220D-16 2+%eps c=sin(%pi) // result is 1.225D-16 and the correct answer should be 0 b==0 // is false but should be true // 8 bits of precision gives: 2^8 //possibilities // if we are measuring a temperature which values are in between 25-100C // the error would be: (100-25)/256

Mrio Eusbio (2013)

Scilab - demo // Just a nice plot xx = linspace(-%pi,%pi,40) yy = linspace(-%pi,%pi,40) plot3d(xx,yy,sinh(xx')*cos(yy)) // 2D plot Y=(x-1)*(x-2)*(x+1)*(x+2)*x a=-1.9:0.01:2.1 b=horner(Y,a) plot(a,b)

Mrio Eusbio (2013)

Transformada Inversa de Laplace


Problema 6a: Encontre a soluo da seguinte equao diferencial

Variveis desvio (processo em torno do estado estacionrio)

quando a varivel manipulada sofre uma variao em degrau unitrio por aplicao de transformadas de Laplace

Mrio Eusbio (2013)

Soluo de uma equao diferencial - transforma inversa usando expanso em fraces parciais -

Mrio Eusbio (2013)

TPC: encontrar a transformada inversa

Transformada Inversa de Laplace


Problema 6b: Represente a equao

Variveis desvio (processo em torno do estado estacionrio)

Em espao de estados e calcule os valores prprios da matriz A DY/dt = AX + Bu

Mrio Eusbio (2013)

s=poly(0,'s') den=s^3+6*s^2+11*s+6 roots(den) A=[0 1 0;0 0 1;-6 -11 -6] spec(A)

Mrio Eusbio (2013)

Transformada Inversa de Laplace


Problema 8 (TPC): Encontre a soluo da seguinte equao diferencial

Variveis desvio (processo em torno do estado estacionrio)

sendo que x(t) representa uma varivel de carga

Mrio Eusbio (2013)

Vous aimerez peut-être aussi