EEE160.1 Lab-Report

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Name of Student(s) - Klifford B. Canoneo & Vann Anthony C.

Viray
Course and Year - BSEE - 3
Date(s) Performed - 16/02/24_
Date Submitted - 22/02/24

Scilab, a powerful open-source numerical analysis software, is a versatile tool for


engineers, scientists, and researchers. With its extensive library of mathematical functions
and intuitive programming environment, Scilab facilitates the exploration and
implementation of complex algorithms across various domains. Scilab offers features for
intricate mathematical problems, simulating dynamic systems, or analyzing data. These
capabilities of Scilaba, along with its user-friendly interface, make it a commonly used
application across engineering, science, and academia.

This activity focuses on mastering the fundamentals of Scilab. It begins with proper
variable declaration, followed by storing arrays and polynomials. Then, it progresses to
conducting arithmetic operations on these variables, ensuring accuracy and precision. Flow
control mechanisms, implementing conditionals such as if-then/else statements, are then
introduced to manage program execution paths. Then, it covers creating functions with
parameters for a reusable code and calling these functions to modify parameters. The
following steps develop a comprehensive understanding of basic and essential Scilab
concepts.

Page 1 of 7
Discuss what
● To introduce students to a mathematical software that can be used to simulate
control systems.

Discuss what

● Personal Computer
● Installation of SCILAB

Page 2 of 7
<Refer to the Activity 1 Manual for the Questions. For your answers, include
screenshots as needed.>

1. How about this one?

-- > b = aaa

What will be the response of the console?


The response of the console is that the variable “aaa” is undefined.

1 2 3
4 5 6
2. What will you enter in the command line if you want to assign a_matrix with
7 8 9
Enter the code in the command line to assign a matrix:

a_matrix = [1, 2, 3; 4, 5, 6; 7, 8, 9]

3. Write the results of (s²+2s +1) / (s+1) as shown in the console.

The result as shown in the console is 1+s / 1.

Page 3 of 7
4. Do a matrix multiplication and element-wise multiplication on a and b. What are the results?
Are the results equal?

13 16
The result for matrix multiplication (a * b) is ⎡⎢ 29 36⎤⎥ . Meanwhile, the result for element-wise
⎣ ⎦
3 8
multiplication (a .* b) is ⎡⎢ 15 24⎤⎥ . The results of both operations are not equal.
⎣ ⎦

5. What is the result of a’?

1 3
The result of a’ assuming the same matrix is used is ⎡⎢ ⎤. This result is the transpose of
4⎥⎦
⎣ 2
matrix a.

Page 4 of 7
6. What is the result of c(1:3,$)
3
6
The result of c(1:3, ) assuming that c = [1, 2 ,3; 4, 5, 6; 7, 8, 9] is
9

7. Write the following in the editor:

a = [0:0.1:2*%pi]
b = “this is executed after a=1”
plot(a,sin(2*a))
// end

What is the result or the behavior of the above statements in the console after executing the
script?
The above statement resulted in a graph of a sine wave with an amplitude of 0.5 and peak of
1.

Page 5 of 7
8. Write a function called myfunc that accepts two parameters A and B. The function will return
the result of (A+B)*B. Execute the script, what is the result?

If a function is defined but not called with specific parameters, it won’t execute any code or
display any results.

9. Call the function you created in #8 and pass as parameters the values 3 and 9. What is the
result?

The result of the following function is 108.

10. What will your function return if the parameters are [1.2.3] and [4;6;7]?

The function will return some sort of error message with the given parameters. The
parameters must have the same dimensions for the function to execute.

11. How about [1, 2, 3 ; 3, 5, 1; 5 6 -1] and [3, -1, 4 ; -3, 5, 1; -5 6 -1]?

Page 6 of 7
The following parameters resulted in a 3 by 3 matrix. The fact that the two parameters have
the identical dimensions allowed the function to operate as intended.

12. Do you have to re-execute your function from SciNotes? Why?

Executing the function again from SciNotes or any other script file is required because Scilab
treats each script or function file as distinct. When a function is defined in a script file and
saved, Scilab doesn't automatically load it into the current session's memory. Thus, to make
the function available for use in the current session, the script file containing its definition
must be run. This process enables Scilab to read and process the script, including the function
definition, and retain it in memory for usage during the session.

<Write your conclusion about the things you did in this lab>
In conclusion, the laboratory activity served as a fundamental introduction to utilizing Scilab. It
covered a diverse range of topics, including variable assignment, matrix operations, arithmetic
calculations, conditional statements, and data plotting. The exercises not only demonstrated correct
methods but also highlighted common mistakes, providing valuable learning experiences. These
exercises equipped us with essential skills for the incoming activities.

Page 7 of 7

You might also like