付録 a scilab 超入門 ??録a scilab 超入門 a.1 scilab...

Download 付録 A Scilab 超入門 ??録A Scilab 超入門 A.1 Scilab ウィキペディアでは次のように説明されている:

Post on 22-Oct-2018

218 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • A Scilab

    A.1 Scilab

    Scilab1990 INRIA*11 ENPC *12 2003 5 ScilabINRIAMATLAB MATLAB (http://ja.wikipedia.org/wiki/scilab)

    URL

    Scilab http://www.scilab.org/ Scilabhttp://www.geocities.jp/rui_hirokawa/

    scilab/

    MATLAB/Scilab20033,045

    A. Quarteroni, F. Saleri, P. GervasioScientificComputing with MATLAB and Octave, 4th edit.,

    Springer, 2014MATLAB Octave2014

    ScilabWebScilabQuarteroniMATLABA.2 Scilab 24

    Scilab -->2 + 3

    [enter/return] 5

    *11 http://www.inria.fr/

    *12 http://www.enpc.fr/

    24 2 + 3

    --> 2 + 3 [enter/return]

    ans =

    5.

    [enter/return] A.3 A.3.1

    --> 3 + 4

    ans =

    7.

    --> 3 - 4

    ans =

    - 1.

    --> 3 + (-4)

    ans =

    - 1.

    --> 3 * 4

    ans =

    12.

    --> 3/4

    ans =

    0.75

    --> 3^4

    ans =

    81.

    --> 4^(-2)

    ans =

    0.0625

    26

    http://ja.wikipedia.org/wiki/scilabhttp://ja.wikipedia.org/wiki/scilabhttp://www.scilab.org/http://www.geocities.jp/rui_hirokawa/scilab/http://www.geocities.jp/rui_hirokawa/scilab/http://www.inria.fr/http://www.enpc.fr/

  • A.3.2

    --> %pi

    %pi =

    3.14159265359

    -->3*%pi

    ans =

    9.424777960769

    --> 2 + 3*%i

    ans =

    2. + 3.i

    -->(2 + 3*%i)*(2 - 3*%i)

    ans =

    13.

    -->%e

    %e =

    2.718281828459

    A.3.3 |x| abs(x)

    x sqrt(x)

    ex exp(x) log x log(x) log10 x log10(x) sinx sin(x) acos x = cos1 x acos(x) tanhx tanh(x) int(x) a/b modulo(a, b)

    // --> sin(10*%pi)+2*cos(3*%pi)

    ans =

    - 2.

    // --> modulo(7, 4)

    ans =

    3.

    // --> int(7/4)

    ans =

    1.

    //

    A.3.4 format 15 20 15 15D+00 100

    --> x = 3.0*%pi

    x =

    9.42477796D+00

    --> format("v",15);

    --> x

    x =

    9.424777960769

    --> format("v",20);

    --> x

    x =

    9.42477796076937935

    --> format("e",15);

    --> x

    x =

    9.42477796D+00

    --> format("e",20);

    --> x

    x =

    9.4247779607694D+00

    ScilabScilab *13int16

    *13 1985 IEEE (Institute of Electrical and Electronics En-gineers)2008 IEEE7542008 binary64

    27

  • --> format("v",10);

    --> n = 1

    n =

    1.

    --> m = int16(1)

    m =

    1

    --> format("e",20);

    --> n

    n =

    1.0000000000000D+00

    --> m

    m =

    1

    A.3.5

    --> who

    A.4 A.4.1 [ ] , ;

    // --> A = [3, -1, 0; 1, 4, 2; 1, 1, 3]

    A =

    3. - 1. 0.

    1. 4. 2.

    1. 1. 3.

    --> B = [-2, 2, 5; 1, 3, 4; 1, -1, 2]

    B =

    - 2. 2. 5.

    1. 3. 4.

    1. - 1. 2.

    // --> 4*A - 2*B

    ans =

    16. - 8. - 10.

    2. 10. 0.

    2. 6. 8.

    --> A*B

    ans =

    - 7. 3. 11.

    4. 12. 25.

    2. 2. 15.

    // --> u = [1, 2, 3]

    u =

    1. 2. 3.

    --> v = [4, 5, 6]

    v =

    4.

    5.

    6.

    --> w = [7; 8; 9]

    w =

    7.

    8.

    9.

    //--> A

    ans =

    3. 1. 1.

    - 1. 4. 1.

    0. 2. 3.

    --> u

    ans =

    1.

    2.

    3.

    --> v

    ans =

    4. 5. 6.

    //--> A*v

    ans =

    7.

    36.

    27.

    --> u*v

    ans =

    32.

    28

  • -->u*u

    ans =

    14.

    [a: h: b]

    [a, a+h, a+2h, ..., b-h, b]

    --> x=[1:0.5:3]

    x =

    1.

    1.5

    2.

    2.5

    3.

    --> x=[1:0.1:2]

    x =

    1.

    1.1

    1.2

    1.3

    1.4

    1.5

    1.6

    1.7

    1.8

    1.9

    2.

    linspace(a, b, n)

    --> linspace(0, 1, 5)

    ans =

    0. 0.25 0.5 0.75 1.

    --> linspace(0, 1, 8)

    ans =

    0.

    0.1428571

    0.2857143

    0.4285714

    0.5714286

    0.7142857

    0.8571429

    1.

    A.4.2

    --> x = [1,2,3];

    --> y = [4,5,6];

    --> A = [3, -1, 0; 1, 4, 2; 1, 1, 3];

    --> B = [-2, 2, 5; 1, 3, 4; 1, -1, 2];

    // // 2--> norm(x, 2)

    ans =

    3.7416574

    --> norm(y, 2)

    ans =

    8.7749644

    // 1--> norm(x, 1)

    ans =

    6.

    // infty--> norm(y, %inf)

    ans =

    6.

    // --> norm(A, 2)

    ans =

    5.2996529

    --> norm(A, 1)

    ans =

    6.

    29

  • --> norm(A, %inf)

    ans =

    7.

    --> norm(A)

    ans =

    5.2996529

    //--> det(A), det(B)

    ans =

    31.

    ans =

    - 36.

    //--> A^(-1)

    ans =

    0.3225806 0.0967742 - 0.0645161

    - 0.0322581 0.2903226 - 0.1935484

    - 0.0967742 - 0.1290323 0.4193548

    --> inv(A)

    ans =

    0.3225806 0.0967742 - 0.0645161

    - 0.0322581 0.2903226 - 0.1935484

    - 0.0967742 - 0.1290323 0.4193548

    ;

    --> x = [1,2,3]

    x =

    1.

    2.

    3.

    --> x = [1,2,3];

    A.4.3

    // --> eye(3, 3)

    ans =

    1. 0. 0.

    0. 1. 0.

    0. 0. 1.

    --> eye(4, 3)

    ans =

    1. 0. 0.

    0. 1. 0.

    0. 0. 1.

    0. 0. 0.

    // 1--> ones(2,3)

    ans =

    1. 1. 1.

    1. 1. 1.

    --> ones(3,3)

    ans =

    1. 1. 1.

    1. 1. 1.

    1. 1. 1.

    //--> zeros(3,4)

    ans =

    0. 0. 0. 0.

    0. 0. 0. 0.

    0. 0. 0. 0.

    //--> rand(2,3)

    ans =

    0.2113249 0.0002211 0.6653811

    0.7560439 0.3303271 0.6283918

    --> rand(2,3)

    ans =

    0.8497452 0.8782165 0.5608486

    0.6857310 0.0683740 0.6623569

    A A A

    --> A=[1,2;3,4];

    --> eye(A)

    ans =

    1. 0.

    0. 1.

    --> zeros(A)

    ans =

    30

  • 0. 0.

    0. 0.

    //

    -->A=[1,2,3,4;5,6,7,8];

    -->eye(A)

    ans =

    1. 0. 0. 0.

    0. 1. 0. 0.

    --> u = [1, 2, 3]

    u =

    1. 2. 3.

    --> A = [1,2,3;4,5,6;7,8,9]

    A =

    1. 2. 3.

    4. 5. 6.

    7. 8. 9.

    //--> diag(u)

    ans =

    1. 0. 0.

    0. 2. 0.

    0. 0. 3.

    --> diag(diag(A))

    ans =

    1. 0. 0.

    0. 5. 0.

    0. 0. 9.

    //--> tril(A)

    ans =

    1. 0. 0.

    4. 5. 0.

    7. 8. 9.

    --> tril(A, 1)

    ans =

    1. 2. 0.

    4. 5. 6.

    7. 8. 9.

    --> tril(A, -1)

    ans =

    0. 0. 0.

    4. 0. 0.

    7. 8. 0.

    //--> triu(A)

    ans =

    1. 2. 3.

    0. 5. 6.

    0. 0. 9.

    --> triu(A, 1)

    ans =

    0. 2. 3.

    0. 0. 6.

    0. 0. 0.

    --> triu(A, -1)

    ans =

    1. 2. 3.

    4. 5. 6.

    0. 8. 9.

    A.4.4 A = (aij) Rnn B = (bij) Rnn

    AB =

    a11b11 a12b12 a1nb1na21b21 a22b22 a2nb2n

    ......

    . . ....

    an1bn1 an2bn2 annbnn

    ,

    AA A m

    =

    am11 a

    m12 am1n

    am21 am22 am2n

    ......

    . . ....

    amn1 amn2 amnn

    ,

    A (1/bij) =

    a11/b11 a12/b12 a1n/b1na21/b21 a22/b22 a2n/b2n

    ......

    . . ....

    an1/bn1 an2/bn2 ann/bnn

    -->A = [3, -1, 0; 1, 4, 2; 1, 1, 3];

    -->B = [-2, 2, 5; 1, 3, 4; 1, -1, 2];

    --> A.*B

    31

  • ans =

    - 6. - 2. 0.

    1. 12. 8.

    1. - 1. 6.

    -->A.^2

    ans =

    9. 1. 0.

    1. 16. 4.

    1. 1. 9.

    -->A./B

    ans =

    - 1.5 - 0.5 0.

    1. 1.3333333 0.5

    1. - 1. 1.5

    A.4.5

    --> u = [1, 2, 3]

    u =

    1.

    2.

    3.

    --> v = [4, 5, 6]

    v =

    4.

    5.

    6.

    --> X = [u, v]

    X =

    1. 4.

    2. 5.

    3. 6.

    --> w = [u ; v]

    w =

    1.

    2.

    3.

    4.

    5.

    6.

    --> z = X(:)

    z =

    1.

    2.

    3.

    4.

    5.

    6.

    -->u = [u, v, v, u]

    u =

    1. 4. 4. 1.

    2. 5. 5. 2.

    3. 6. 6. 3.

    A.5 2DA.5.1 0 x y = sinxx [0, 2] 20 1 x x y sinx plot2d

    --> x = linspace(0, 2*%pi, 20);

    --> y = sin(x);

    --> plot2d(x, y)

    25

    x y

    32

  • --> x = linspace(0, 2*%pi, 20);

    --> y = sin(x);

    --> plot2d(x, y)

    A.5.2

    --> x = linspace(0, 2*%pi, 100);

    --> y = sin(x);

    --> plot2d(x, y);

    --> y = sin(3.0*x);

    --> plot2d(x, y)

    26

    27

    --> x = linspace(0, 2*%pi, 100);

    --> y = sin(x);

    --> plot2d(x, y, style = 5);

    --> y = sin(3.0*x);

    --> plot2d(x, y, style = 2);

    style

    27

    1 5 2 6 3 7 4

    RGB color(r, g, b) rgb0 255

    --> plot2d(x, y, style = color(255, 224, 224));

    28 100 xy1y2100 2 [y1, y2] plot2d plot2d(x, y1) (x, y2)

    --> x = linspace(0, 2*%pi, 100);

    --> y1 = sin(x);

    --> y2 = sin(3.0*x);

    --> plot2d(x, [y1, y2]);

    27

    33

  • 28

    --> x = linspace(0, 2*%pi, 100);

    --> y1 = sin(x);

    --> y2 = sin(3.0*x);

    --> plot2d(x, [y1, y2], style=[5,2]);

    A.5.3

    29

    --> x = linspace(0, 2*%pi, 100);

    --> y1 = sin(x);

    --> y2 = sin(3.0*x);

    --> plot2d(x, [y1, y2], style=[5,2]);

    // -->xgrid();

    // // (1: ) (2: ) (3: ) (4: )--> legend("sin(x)", "sin(3x)", 1);

    // --> title("");--> xlabel("x");

    --> ylabel("y");

    // --> xtitle("","x","y");

    A.5.4

    Scilab

    29

    30

    >

    30 31fig1.pdffig1.eps 31

    31

    34

  • : fig1 PDF

    : fig1

    (EPS)

    0

    --> xs2pdf(0, "fig1.pdf")

    --> xs2eps(0, "sinx.eps")

    0, 1, 2, . . .

    --> scf(4); // 4--> plot2

Recommended

View more >