[Contents] [TitleIndex] [WordIndex

Colorized source displays for scilab scripts

scripts

function [xr,yr,zr,xi,yi,zi] = CmplxFacets(R,e,TypeDomain,TypeCut,n,StrFunc)

        //  A function to compute the facets for drawing a complex function
        //  on a square or a disk with branch(es) cut(s) on Ox or Oy
        //
        //  TypeDomain : "Square" or "Disk"
        //     TypeCut : "Ox" or "Oy"
        //           R : length of half a side of the square or radius of the disk
        //           e : thin layer to avoid the branch(es) cut(s)
        //           n : a scalar (for Square) or a 2-vector = [ntheta, nr]
        //               (for Disk) for discretization
        //     StrFunc : the string which names the complex function (this is
        //               because primitive don't pass as function argument)
        
        if TypeDomain == "Square" then
                if TypeCut == "Ox" then
                        x1 = linspace(-R, R, n);
                        y1 = linspace( e, R, n/2);
                else  // for TypeCut = "Oy" ...
                        x1 = linspace( e, R, n/2);
                        y1 = linspace(-R, R, n);
                end
                X1 = ones(y1')*x1 ; Y1 = y1'*ones(x1);
        else // for TypeDomain = "Disk"
                r = linspace(0,R, n(2));
                if TypeCut == "Ox" then
                        theta = linspace(0,%pi,n(1))';
                        X1 = cos(theta)*r;
                        Y1 = e + sin(theta)*r;
                else // for TypeCut = "Oy"
                        theta = linspace(-%pi/2,%pi/2,n(1))';
                        X1 = e + cos(theta)*r;
                        Y1 = sin(theta)*r;
                end
        end
        X2 = -X1 ; Y2 = -Y1;
        Z1 = evstr(StrFunc+"(X1 + %i*Y1)");
        Z2 = evstr(StrFunc+"(X2 + %i*Y2)");
        [xr1,yr1,zr1] = nf3d(X1,Y1,real(Z1));
        [xr2,yr2,zr2] = nf3d(X2,Y2,real(Z2));
        xr = [xr1 xr2]; yr = [yr1 yr2]; zr = [zr1 zr2];
        [xi1,yi1,zi1] = nf3d(X1,Y1,imag(Z1));
        [xi2,yi2,zi2] = nf3d(X2,Y2,imag(Z2));
        xi = [xi1 xi2]; yi = [yi1 yi2]; zi = [zi1 zi2];
endfunction 

console output

-->A=diag([2,3,4]);B=[1 0;0 1;0 0];C=[1 -1 0];D=0*C*B;x0=[0;0;0];

-->Sl=syslin('c',A,B,C,D,x0)    //Standard state-space linear system
 Sl  =
 
 
       Sl(1)   (state-space system:)
 
!lss  A  B  C  D  X0  dt  !
 
       Sl(2) = A matrix = 
 
    2.    0.    0.  
    0.    3.    0.  
    0.    0.    4.  
 
       Sl(3) = B matrix = 
 
    1.    0.  
    0.    1.  
    0.    0.  
 
       Sl(4) = C matrix = 
 
    1.  - 1.    0.  
 
       Sl(5) = D matrix = 
 
    0.    0.  
 
       Sl(6) = X0 (initial state) = 
 
    0.  
    0.  
    0.  
 
       Sl(7) = Time domain = 
 c
 
-->Sl("A"), Sl("C")             //Retrieving elements of a typed list
 ans  =
 
    2.    0.    0.  
    0.    3.    0.  
    0.    0.    4.  
 ans  =
 
    1.  - 1.    0.  

-->Slt=ss2tf(Sl)                // Transfer matrix
 Slt  =
 
      1       - 1     
    -----     -----   
  - 2 + s   - 3 + s   

-->Slt('num'), Slt('den')
 ans  =
 
    1   - 1   
 ans  =
 
  - 2 + s   - 3 + s   

2022-09-08 09:27