Gerardo starting with the word atomI in the

                                                 Gerardo L. Lo                       Midterm                      01/11/2018                         EE42FB1                              Assignment 1                        Engr.

LagunaINTRODUCTION TO SCILABEXERCISE 1.7Exercise 1.1 (Installing Scilab) Install the current version of Scilab on your system: at the time where this document is written, this is Scilab v5.2. It is instructive to install an older version of Scilab, in order to compare current behavior against the older one. Install Scilab 4.1.2 and see the differencesThe current version of the Scilab in the website is now at v6.

0.0, the figure 1.1 shows the new console window of Scilab v.6.0.0. Using the help function, the window shows the Scilab home window at help browser which shows the current version of the Scilab and the new features of the version as shown in figure 1.

2..Figure 1.1. This figure shows the Scilab 6.

Best services for writing your paper according to Trustpilot

Premium Partner
From $18.00 per page
4,8 / 5
4,80
Writers Experience
4,80
Delivery
4,90
Support
4,70
Price
Recommended Service
From $13.90 per page
4,6 / 5
4,70
Writers Experience
4,70
Delivery
4,60
Support
4,60
Price
From $20.00 per page
4,5 / 5
4,80
Writers Experience
4,50
Delivery
4,40
Support
4,10
Price
* All Partners were chosen among 50+ writing services by our Customer Satisfaction Team

0.0 console window.     Figure 1.2. This figure shows the command from the console and the Scilab home help window contents. Exercise 1.

2 (Inline help: derivative) The derivative function allows to compute the numerical derivative of a function. The purpose of this exercise is to find the corresponding help page, by various means. In the inline help, find the entry corresponding to the derivative function. Find the corresponding entry in the online help. Use the console to find the help.The help derivative shows the help window at the derivative page which includes the block diagram, palette, description and others about the function as shown in figure 1.3.

        Figure 1.3. This figure shows the command and the content of derivative function at the help window. Exercise 1.3 (Asking a question on the forum) You probably already have one or more questions.

Post your question on the users’ mailing list [email protected] EXERCISE 2.6Exercise 2.1 (The console) Type the following statement in the console. atoms Now type on the key. What happens? Now type the “I” letter, and type again on . What happens?In the word “atoms” plus key, the functions starting with the word atoms are being displayed by a list box pop-up window shown in figure 2.

1. Also in addition with the letter “I” in it plus key displays the functions starting with the word atomI in the list box pop-up window shown in figure 2.2.    Figure 2.1. This figure shows the list box pop-up window to browse the ATOMS functions.

    Figure 2.2. This figure shows the list box pop-up window to browse the ATOMSI functions. Exercise 2.2 (Using exec) When we develop a Scilab, script we often use the exec function in combination with the ls function, which displays the list of files and directories in the current directory. We can also use the pwd, which displays the current directory. The SCI variable contains the name of the directory of the current Scilab installation.

We use it very often to execute the scripts which are provided in Scilab. Type the following statements in the console and see what happens.pwd SCI ls ( SCI +” / modules “)ls ( SCI +” / modules / graphics / demos “) exec ( SCI +”/ modules / graphics / demos /2d_3d_plots / contourf . dem . sce “) exec ( SCI +”/ modules / graphics / demos /2d_3d_plots / contourf . dem . sce ” );The pwd shows the current directory path of the Scilab files such as location of the save files of the Scilab program while SCI shows the current directory folder of the current Scilab installation as shown in the figure 2.

3 and figure 2.4 respectively. The use of SCI + “/modules” create a string which concatenate the Scilab installation directory name and the “/modules” string as shown in figure 2.

5. Therefore the third line displays the list of files in the modules subdirectory of the Scilab installation folder as shown in figure 2.6. Same goes with the fourth line displaying the list of files in the “Scilab installation folder”/modules/graphics/demos address as shown in figure 2.7.

The exec function executes or run the program declared for which is the countourf.dem.sce Scilab file under the following directory path as shown in figure 2.8. The use of semicolon “;” at the end of the program line will not display the content of the file when the script is executed as shown in figure 2.9, which is quite useful for scripts containing many lines of functions with specific output display.    Figure 2.

3. This figure shows the current directory path of the Scilab files.   Figure 2.4. This figure shows the current directory path of the Scilab installation folder. Figure 2.

5. This figure shows the string concatenation of the Scilab installation folder string and the “/modules” string. Figure 2.

6. This figure shows a portion of the file contents at the subfolder modules under Scilab Installation directory path. Figure 2.7.

This figure shows the file contents of the graphic demos under the directory path declared.Figure 2.8. This figure shows the demo contourf.

dem.sce Scilab file under the Scilab installation directory.Figure 2.9. This figure shows the output of the previous command with semicolon at the end of the program line.EXERCISE 3.

13Exercise 3.1 (Precedence of operators) What are the results of the following computations (think about it before trying in Scilab)?2 * 3 + 4 2 + 3 * 4 2 / 3 + 4 2 + 3 / 4Using arithmetic MDAS rule, the first expression has a value of 10, while the second one has value of 14, the third one having 4.6666667 and lastly the fourth one having 2.75. As shown in figure 3.1 which has the same equivalent answer in the above shows that Scilab program also performs mathematical MDAS rules.    Figure 3.1.

This figure shows the commands and answers of the expressions above using Scilab console.Exercise 3.2 (Parentheses) What are the results of the following computations (think about it before trying in Scilab) ?2 * (3 + 4) (2 + 3) * 4 (2 + 3) / 4 3 / (2 + 4)Using arithmetic PEMDAS rule, the expression will follow first the operation within the parenthesis before others for which the first expression has a value of 14, while the second one has value of 20, the third one having 1.

25 and lastly the fourth one having 0.5. As shown in figure 3.2 which has the same equivalent answer in the above shows that Scilab program also performs operation within the parenthesis first.     Figure 3.2.

This figure shows the commands and answers of the expressions above using Scilab console.Exercise 3.3 (Exponents) What are the results of the following computations (think about it before trying in Scilab) ? 1.23456789 d10 1.23456789 e10 1.23456789 e -5The number after the letter’d’ provided at this expressions defines the exponent of the constant number before it.

In other ways, the letter ‘e’ can be used also to represent the exponent of the following constant but computes the constant of the following for which evaluates the value as much as possible otherwise represent the output value in terms of exponential ‘d’ letter. The first expression shows a 1.23456789*10 raised to the tenth power which is also the same with the second expression, while the third expression is equivalent to 1.

23456789*10 raise to the negative fifth power or can be evaluated to 0.0000123456789. The figure below shows that the following exponents has been rounded off to the nearest 3 to 4 non-zero digit number as shown in the figure below.Figure 3.

3. This figure shows the output of the expressions above using Scilab. Exercise 3.4 (Functions) What are the results of the following computations (think about it before trying in Scilab) ?sqrt (4) sqrt (9) sqrt ( -1) sqrt ( -2) exp (1) log ( exp (2)) exp ( log (2)) 10^2 log10 (10^2) 10^ log10 (2) sign (2) sign ( -2) sign (0)The mathematical equivalent of the square root of the expressions are 2, 3, i, and 1.414i respectively. The sqrt( ) function determines the square root of the constant or variable which output the square root of the constant provided it is greater than zero and provides complex or imaginary answer for such constant less than zero as shown in Figure 3.4.         Figure 3.

4. This figure shows the output of the square root functions for the expressions above using Scilab. The mathematical equivalents of the following exponential and logarithmic functions are 2.7183, 2, 2, 100, 2, and 2 respectively. The exp( ) function provides the exponential function for which the constant argument is the exponent for the base of natural number e ? 2.7183. The log ( ) function provides the natural logarithm of the argument which is inverse function of the exponential function for which as shown in figure 3.

5 that the natural logarithm of the exponential function or vice versa of the argument is equivalent to the argument itself. The ^ provides the operation for exponent while the log10 ( ) function provides the logarithm of the argument to the base 10.              Figure 3.5. This figure shows the output of exponential and logarithmic functions for the expressions above using Scilab. The sign ( ) function provides the polarity of the argument such that it outputs 1 for positive number, -1 for negative number and 0 for zero. The mathematical results of the functions above are 1, -1, and 0 respectively.

This is also equivalent to the simulation shown below.Figure 3.6. This figure shows the output of the signs for the expressions above using Scilab. Exercise 3.

5 (Trigonometry) What are the results of the following computations (think about it before trying in Scilab) ? cos (0) sin (0) cos ( %pi ) sin ( %pi ) cos ( %pi /4) – sin ( %pi /4) The use of %pi is equivalent to the constant ? which is approximately 3.14 in value. The cos ( ) function provides the cosine equivalent of the argument while the sin ( ) function provides the sine equivalent of the argument. In mathematical operation, the results to the following expressions are 1, 0, -1, 0, and 0 respectively. It can be observed that the sin (?) result in Scilab is a very small number but not zero since Scilab approximately use a constant value approximately ? in value as shown in the figure below.                 Figure 3.7.

This figure shows the output of the trigonometric functions for the expressions above using Scilab.EXERCISE 4.18Exercise 4.1 (Plus one) Create the vector (x1 + 1, x2 + 1, x3 + 1, x4 + 1) with the following x. x = 1:4;The figure below shows that the output of the code used in Scilab provides an output equivalent of matrix x for which the output when subjected to operations provide the operation of each element in the vector. Thus the scalar 1 is added to each element of the matrix x.

Figure 4.1. This figure shows the output and Scilab code simulation of the above exercise. Exercise 4.

2 (Vectorized multiplication) Create the vector (x1y1, x2y2, x3y3, x4y4) with the following x and y. x = 1:4; y = 5:8;The figure below shows the multiplication operation for two matrix x and y for which it should be taken consider to use element-wise multiplication “.*” to be able to multiply the matrix element by element as in the above output vector.Figure 4.2. This figure shows the output and Scilab code simulation of the above exercise. Exercise 4.

3 (Vectorized invert) Create the vector (1/x1 , 1/x2 , 1/x3 , 1/x4)with the following x. x = 1:4;The figure below shows the inverting of matrix x using element-wise division “./” to be able for the output matrix to be equivalent to perform element by element division of the matrix which is the provided output in the problem.Figure 4.3. This figure shows the output and Scilab code simulation of the above exercise.

 Exercise 4.4 (Vectorized division) Create the vector ( x1/y1 , x2/y2 , x3/y3 , x4/y4) with the following x and y. x = 12*(6:9); y = 1:4;The figure below shows the division of two input matrix x and y using element-wise division “./” to be able for the output matrix to be equivalent to perform element by element division of the matrix which is the provided output in the problem.

Figure 4.4. This figure shows the output and Scilab code simulation of the above exercise. Exercise 4.

5 (Vectorized squaring) Create the vector x21, x22, x23, x24 with x = 1, 2, 3, 4.The figure below shows the squaring of a input matrix x using element-wise squaring operation “.^” to be able for the output matrix to be equivalent to perform element by element multiplication of the matrix to itself which is the provided output in the problem.Figure 4.5. This figure shows the output and Scilab code simulation of the above exercise. Exercise 4.6 (Vectorized sinus) Create the vector (sin(x1), sin(x2), .

. . , sin(x10)) with x is a vector of 10 values linearly chosen in the interval 0, ?.The figure below uses the function linspace for which it divides the range 0 to ? into10 equally divided interval including the initial and end interval.

After that the matrix x is used in sine function for which every element of matrix x will be operated in sine which is the output of the problem. Figure 4.6. This figure shows the output and Scilab code simulation of the above exercise. Exercise 4.7 (Vectorized function) Compute the y = f(x) values of the function f defined by the equation                                                         f(x) = log10 (r/10x + 10x )                                                   (1)with r = 2.

220*10?16 and x a vector of 100 values linearly chosen in the interval ?16, 0.Figure 4.7. This figure shows the output and Scilab code simulation of the above exercise.