You are on page 1of 6

FEU INSTITUTE OF TECHNOLOGY

College of Engineering and Computer Studies

DATA

Data Analysis
In this activity, Custom Functions and Scripts it can be seen that scripts are treated by
MATLAB as simply to execute the commands found in the file. Also, scripts can produce graphical
output using plot. With functions, these are files that can accept input arguments and return output
argument. Also, functions can operate on its workspace or in separate workspace.
On the first command wherein for loop is used and variable i was declared to have an
iteration up to 10. These function is extracted to the myRand that is recognized by MatLab to select
a random number in an array. Executing the next command wherein rand is used. It can be seen
that MatLab automatically display random numbers. With that command, declaration of variable
i is not needed for the random display of numbers.
Next is creating a function z with a function name of ellipseArea. In this function values of
axis1 and axis2 should be given to be able to be used in determining the area of the ellipse. Inserting
the formula of the area of ellipse on z which is pi multiplied by the length of axis 1 and axis 2.
Executing these function and putting the values of axis1 and axis2 in it, MatLab was able to
recognized and give an output based on the given equation.

With the plotSine function wherein maxVal is used to determine the amplitude of a sinusiod
and theta to be the value of phase shift. The variable t was declared for easier determination or the
starting point, step size and the end point of the sinusoid. Applying it together with the given
function MatLab recognized it and display an output waveform based on what is declared on the
function. These function is used in three different values of theta and it is observed that the three
output waveforms have the same amplitude but differ on its time shifts since different values of
theta were used in the three sinusoids.
The last function where we should create our own function that when a magnitude and an
angle is used as an input, the function myPolarToRect will display the equivalent value of the polar
form in rectangular form. Recalling the principles on how to convert polar form into rectangular
form, the function is created following the Euler's Identity, cis theta where in the magnitude is
being multiplied to the sum cosine of the angle converted in radians and sine of the angle that is
also in radians together with the imaginary number i. Executing the function, the rectangular form
is obtained with the input of magnitude and angle in degrees.
Upon performing this activity, I was able to know that MatLab can perform different
functions. There are a lot of ways on how to obtain an output using functions and scripts. It can be
applied in mathematical computations especially on engineering problems. I was able to create my
own script in order to solve a specific problem and manipulating it to have different output.

Conclusion
In this activity, it can be concluded that scripts are simple programs since the
commands are stored as being executed in the command line. However, by using functions the
program can be more flexible and easily extensible. When running a script, it stores the result in
the declared variable in the workspace. With that, instead of manually changing the script every
time, function can be created and when calling the program that is to be executed, the function
name should be included first followed by the input arguments. Using functions allows the user
to manipulate the program easily.
Also, scripts do not accept input arguments or return output argument. It is only operating
on the workspace while functions accepts input arguments and return output arguments. The
internal variables are locally recognized by the function. These can be applied in performing a
certain system that follows series of commands.

You might also like