58f947bd674cc0cf822406ebc69223e8af392aff
[scilab.git] / scilab / modules / core / demos / intro / operations.dem.sce
1 //
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) ????-2008 - INRIA
4 //
5 // This file is distributed under the same license as the Scilab package.
6 //
7 mode(7)
8 //To quit this demo, enter CTRL+C, then type "abort"
9
10 //                  OPERATIONS
11 v=1:5;W=v'*v                 //constant matrix multiplication
12 W(1,:)                       //extracting first row
13 W(:,$)                       //extracting last column
14 Mp'*Mp+eye()                   //polynomial matrix
15 Mp1=Mp(1,1)+4.5*%i           //complex
16 Fi=C*(z*eye()-A)^(-1)*B;       //transfer function evaluation
17 F(:,1)*Fi                    //operations with rationals
18 M=[Mp -Mp; Mp' Mp+eye()]       //concatenation of polynomial matrices
19 [Fi, Fi(:,1)]                // ... or rationals
20 F=syslin("c",F);
21 Num=F("num");Den=F("den");           //operation on transfer matrix
22
23 //                  SOME NUMERICAL PRIMITIVES
24 inv(A)                       //Inverse
25 inv(Mp)                      //Inverse
26 inv(Sl*Sl')                  //Product of two linear systems and inverse
27 w=ss2tf(ans)                 //Transfer function representation
28 w1=inv(ss2tf(Sl)*ss2tf(Sl'))    //Product of two transfer functions and inverse
29 clean(w-w1)
30 A=rand(3,3);;B=rand(3,1);n=contr(A,B)                 //Controllability
31 K=ppol(A,B,[-1-%i -1+%i -1])        //Pole placement
32 poly(A-B*K,"z")-poly([-1-%i -1+%i -1],"z")    //Check...
33
34 s=sin(0:0.1:5*%pi);
35 ss=fft(s(1:128),-1);        //FFT
36 my_handle = scf(100001);clf(my_handle,"reset");
37 plot2d3("enn",1,abs(ss)'); //simple plot