12.07.2015 Views

Introduction to Scilab - Projects

Introduction to Scilab - Projects

Introduction to Scilab - Projects

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

cholcompanionconddetinvlinsolvelsqluqrrcondspecsvdtestmatrixtraceCholesky fac<strong>to</strong>rizationcompanion matrixcondition numberdeterminantmatrix inverselinear equation solverlinear least square problemsLU fac<strong>to</strong>rs of Gaussian eliminationQR decompositioninverse condition numbereigenvaluessingular value decompositiona collection of test matricestraceFigure 23: Some common functions for linear algebra.5.1 The if statementThe if statement allows <strong>to</strong> perform a statement if a condition is satisfied. Theif uses a boolean variable <strong>to</strong> perform its choice: if the boolean is true, then thestatement is executed. A condition is closed when the end keyword is met. In thefollowing script, we display the string ”Hello!” if the condition %t, which is alwaystrue, is satisfied.if ( %t ) thendisp (" Hello !")endThe previous script produces:Hello !If the condition is not satisfied, the else statement allows <strong>to</strong> perform an alternativestatement, as in the following script.if ( %f ) thendisp (" Hello !")elsedisp (" Goodbye !")endThe previous script produces:Goodbye !In order <strong>to</strong> get a boolean, any comparison opera<strong>to</strong>r can be used, e.g. ”==”, ”>”,etc... or any function which returns a boolean. In the following session, we use the== opera<strong>to</strong>r <strong>to</strong> display the message ”Hello !”.i = 2if ( i == 2 ) thendisp (" Hello !")else34

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!