Vous êtes sur la page 1sur 3

DATA ANALYSIS

From the activity Custom Functions and Scripts, creation of functions


which is from the compilation of different commands in done, where codes
are written on the script.
The initial commands which are executed are remnants from the past
activities about matrix. In for-loop is a type of iterative command, which
executes through the satisfied condition which is declared. It is observed
that, the for-loop command is applied through the creation of a 1x10 matrix
where each elements are due to the random command for 1x1 matrix
executed for each values of i as declared (from i=1:10). As alternative, a
random command can also be used where the number of columns and rows
are declared, which produces a desired dimension matrix with random
elements.
For the activity per se; creation of an M-File is introduced. This M-File is
in a form of script or functions where codes are to be written which will be
executed by the command window upon calling the name of the function
called.
The first function created is an area solver for an ellipse given its two
axes as inputs. The algorithm of this solver, based on what was written on
the codes is as follows:

Calling of the function name created together with the desired


inputs
Displaying the values of the two inputs namely the axes
Displaying the answer for the area of the ellipse

Upon implementation it is observed that, proper input arguments are


required
to which these arguments reflect with the independent variable as declared
from the function creation.
The second function created is a Sine Function plotter. Having the
maxVal as the max value for the waves amplitude and theta for the waves
phase shift the algorithm of the plotter is as follows:

Calling of the function name created together with the desired


inputs
A range of values which denotes the values for the x-axis
including the step for the waveform as declared in an array
Application of the input values into the sin function where theta
as input will serve as the phase shift for the wave

The function is observed from the implementation of it with 3 different values


for amplitude and theta. It is observed that for the three different callings of
the function created with different input arguments, the graph reflected it. As
observed from the three different values, they all have the same amplitude
as maxValue but different phase shifts where the wave started to generate
as reflection for the theta input which is the phase shift.
It is observed from the two functions created that, the input arguments
upon calling the function name must reflect with the input arguments require
to execute the function. Also, it is observed that on creating a function, the
name of the M-File must be the same with the name of function (function of y
= plotSine (x1,x2) ). This same name will serve as the execution requirement
of the function in order to be familiarized by the Matlab. Additionally, names
of the functions must be carefully evaluated, to avoid naming functions
which are already built-in on the Matlab console.
For the commands on the script created, commands which are executed on
the command window are used there where commands which needed an
end must be terminated properly with the correct syntax.
As exercise for this activity, creation of a polar to rectangular is done
with the use of a function creation through script which is saved also as an
M-File. The function created have the algorithm as follows:

Calling of the function which have an input arguments of (r,


angle) on a polar form
Conversion of the input angle to degrees (in Matlab, radians is
the default)
Utilization of those inputs in cosine and sine as reflection to the
rectangular form
Making the output in x+yi form

Upon implementation, it is observed that the function created executed the


conversion of polar values into rectangular in the form of x+yi. It is observed
that the argument (angle) to be inputted must be in degrees.
As insights from the activity, it can be said that Matlab is capable of
creating specific function which are useful for many applications such as in
Mathematics and Applied Engineering Sciences. From the scripts of functions
created, we can devise functions which would be able to solve other types of
conversion such as conversions of measurements, engineering constants
could also be stored where upon calling for example Engineering Constants
on the command window, a library of learned constants will be output. The

application also could be done collaboratively with the previous activities


such as the matrix.

CONCLUSION
From the activity Custom Functions and Scripts, it can be concluded
that there is a difference within scripts and functions. Functions have its
independent and independent variables within its creation, where within its
process commands which are used on Matlab can be applied, while script is
also an M-File, but it can be created with random instructions as Matlab
commands are used.
For the function creation and implementation, the input arguments
must agree with the independent variables declared on the function
declaration. Also, when calling the said function on the command window,
the name of the function must be the same with the M-File of it saved.
It can be concluded that, script programming is the use of codes, or
commands stored within the software as executing a certain algorithm. As an
application, function creation is done with a systematic processing of the
variables declared on the function declarations.

Vous aimerez peut-être aussi