You are on page 1of 6

ECE-MATH313 Machine Problem 1

1st Term, A.Y. 2015 2016


John Ianne Miguel T. Garcia, Jasmin D. Raca, Limuel Z. Ruiz
Section 3ECE-A, Department of Electronics Engineering
Faculty of Engineering, University of Santo Tomas, Manila, Philippines
garcia.ianne@gmail.com, jasminraca20@gmail.com, ruiz.limuel@yahoo.com
Abstract - In this paper, two machine problems in Vector
Analysis are solved and plotted through the language of
MATLAB. In problem one, two cylindrical vectors are given;
their cross product, the output vector, together with the input
vectors, were plotted. In problem two, a spherical vector field
and set of values were given. The various combinations of
points for test values were plotted.
Using the formulas learned in Vector Analysis, the group
was able to synthesize the desired output. The expounded step
by step solutions, formulas, built in functions and codes used
are found in the Discussion of Question and shown in
Appendix.

algorithm, function and syntax for plotting vectors is much


easier to code in MATLAB.
Solving the machine problem didnt only enhance the
members analytical and critical thinking skills but also
develop their understanding in two courses: (1) Vector
Analysis (2) Technical Computing. By documenting, the
group was able to apply their writing skills and work as a
unified team. Furthermore, it allowed the group to devise
learning algorithms by seeking methods in developing a
computer based program which would provide their desired
output.
II. DISCUSSION OF QUESTION 1

Index Terms - Vector quantity, Scalar quantity, Scalar


Component, Vector Field, Cross Product, Matrix, Dot Product,
Perpendicular, Parallel

I. BACKGROUND OF THE STUDY


Physical quantities, such as force and temperature, can be
categorized into two: (1) Scalar quantity which is described
by magnitude alone, and (2) Vector quantity which is
represented by both magnitude and direction in space, and
specified by coordinates [1]. These coordinates can be
expressed through Rectangular Coordinate System (x, y z),
Cylindrical Coordinate System (p, ,z) and Spherical
Coordinate System (r, ,). Vector field describes the
different vectors in various points of space, while scalar
component of a vector quantity is defined as the magnitude
of the vector in the different axis or directions [2].The cross
product of two vectors is equal to the product of their
magnitudes and the sine of the angle between them.
Furthermore, cross product can be solved through the matrix
or determinant expansion by minors. When orthogonal
vectors are parallel to each other, their cross product is equal
to zero. On the other hand, when they are perpendicular to
each other, their dot product is equal to zero. In problem one,
the group was asked to compute and plot the cross product of
two cylindrical vectors. In problem two, the spherical vector
field at various integer points.
The group has chosen MATLAB as their programming
language. MATLAB is a high-level language and interactive
environment for numerical computation, visualization, and
programming. Using MATLAB, the user can analyze data,
develop algorithms, and create models and applications.
Unlike any other language, it is more optimized for
operations involving matrices and vectors [3]. Second, the
group is more knowledgeable in MATLAB since they are
currently taking Technical Computing course. Lastly, the

This section will discuss and further explain the


mechanics of problem one.
A. Question
Problem one asks the group to compute and plot - in 3D,
front view, right side view and top view, the cross product
of two given cylindrical vectors which values are :
1.) = 2 + 3
= +

P ( 2, 30, 4)
2.) = + 2
= 2 +

P ( 2, 0, 4)
The initial points given, as well as the scalar components,
should be inputted in array form.
B. Solution
First, a function definition line was inputted with values
of,
, rho, phi and z. Rho, phi and z are the given
are the vector input in
coordinate points, while
CCS. Note that the angle rho must be in degrees. There are
also two outputs given, vector in RCS and vector in CCS.
Second, the given vectors must be converted into
Rectangular Coordinate System because cross product
function requires vector in RCS. The conversion was made
possible using the table:
Table1. Table used for converting RCS and CCS

az

Ax

cos

-sin

Ay
Az

sin
0

cos
0

0
1

Then, the built-in function cross (A, B) computes for


in RCS. RCS should lastly
the cross product of vector x
be converted to CCS again using Table1, since thats what
the problem requires. Subsequently, a three-dimensional
quiver plot displays vectors with components (Ax, Ay, Az)
at the points (x, y, z). The matrices must all be the same size
and contain the corresponding position and vector
components [4]. Using the built-in function quiver3 (x, y, z,
Ax, Ay, Az), this would plot the input vectors together with
output. Hold on code was used so that all the input vector
field and output vector field shall be plotted.
The program created only allows the user to input vector
components in CCS form, altering the input components
leads to error in algorithm. Also, the input must follow
),,
strictly the format and arrangement of values - [( ), (
, z]. When inputting the values for function, the user must
input the code: CrossProd ([1,-2,3],[1,1,-1],2,30,4) for test
value 1 and CrossProd ([1,-2,-1],[0,2,1],2,0,4) for test value
2.

, and output
Fig. 2 shows the plot of input vectors,
vector
, in RCS form, in top view 2D plot (x, y). The blue
vector represents, red vector represents
and output

vector is shown in black.

C. Results
Based on the output figure, the algorithm of the code was
correct since the output vector is perpendicular to the input
vectors. It was proven in the Appendix that the three vectors
are perpendicular through dot product.
Fig.1-8 shows the graph of the three perpendicular
vectors. Although it cant be clearly observed in the figures,
when the user generated the figure in the right angle one can
see their perpendicularity.
Fig. 1 shows the plot of input vectors = 1.8660
= 0.3660 + 1.3660
1.2320 + 3
and

, and
output
vector
= 2.866 + 2.964 +
2.9998 in 3D projection with the plots(x, y, z). The blue
vector represents, red vector represents
and output
vector is shown in black.

, and output
Fig. 3 shows the plot of input vectors,
vector
, in RCS form, in front view 2D plot (y, z). The blue
vector represents, red vector represents
and output

vector is shown in black.

Fig. 2. Test Value 1 in top view RCS generated using MATLAB.

Fig. 3. Test Value 1 in front view RCS generated using MATLAB.

, and output
Fig. 4 shows the plot of input vectors,

vector , in RCS form, in right side view 2D plot (x, z). The
blue vector represents, red vector represents
and output
vector is shown in black.

Fig. 1. Test Value 1 in 3D RCS generated using MATLAB.

Fig. 7 shows the plot of input vectors


vector
, in RCS form, front view 2D plot (y,
vector represents, red vector represents

vector is shown in black

output
,
z). The blue
and output

Fig. 4. Test Value 1 in right side view RCS generated using MATLAB.

Fig. 5 shows the plot of input vectors = + 2


= 2 + output vector
and
= 4 +
2 in 3D projection with the plots(x, y, z). The blue vector
represents, red vector represents
and output vector is
shown in black.

Fig. 7. Test Value 2 in front view RCS generated using MATLAB

output
Fig. 8 shows the plot of input vectors ,
vector
, in RCS form, top view 2D plot (x, z). The blue
vector represents, red vector represents
and output
vector is shown in black

Fig. 5. Test Value 2 in 3D RCS generated using MATLAB

output
Fig. 6 shows the plot of input vectors ,
vector
, in RCS form, top view 2D plot (x, y). The blue
vector represents, red vector represents
and output
vector is shown in black.

gffg

Fig. 8. Test Value 2 in right side view RCS generated using MATLAB

Table 2 displays the values for inputting the vectors


and the desired output in CCS.
Table 2. Table for input and output vectors in CCS for trial 1 and 2

Trial 1

Trial 2

Input
= 2 + 3
= +

P ( 2, 30, 4)

Output
- +4+ 3az

= + 2
= 2 +

P ( 2, 0, 4)

4 -+ 2az

Fig. 6. Test Value 2 in top view RCS generated using MATLAB

III. DISCUSSION OF QUESTION 2


This section will discuss and further explain the
mechanics of problem two.
A. Question
In problem two, the group was asked to input a function
that would plot the spherical vector field in 3D, top view,
right side view and front view, at given various spherical
points. The plot must show the correct directions and their
magnitudes may be scaled for improved evaluation. The
vector field given was: = +
. The vector field must be plotted using two trial
values given in the table:
Table3. Table for values of trial 1 and 2
r= ( 0,1,2,3)
= ( 0,30,60,90,120,150,180)

r= ( 0,1,2,3)
= ( 0,30,60,90,120,150,180)

= ( 0,60,120,180,240,300)

= ( 0,60,120,180,240,300)

B. Solution
First, a function definition line was inputted with the
values of (r, ,), wherein r is the set of radius coordinates,
is the set of angle theta coordinates and is the set of
angle phi coordinates.
In this problem, a for-loop statement was used in order to
test values for the three set of components. For statements
loop a specific number of times, and keep track of each
iteration with an incrementing index variable [4]. Loop 1 was
used to test set values of r, loop 2 was used to test set values
of angle theta and loop 3 was used to test set values for angle
phi.
Then, each elements of set r, set theta and set phi must be
converted into their respective RCS coordinates. The
formula used for converting x is x = rsincos; the formula
for converting y is y = rsinsin; the formula converting z is
z= rcos. The scalar components obtained should then be
converted from SCS to RCS. Table 4 was used for
conversion.

theta), (angle phi)]. The m file converter.m, found in zip file,


manually accept the sets of values given and outputs all
possible combinations, while m file Field.m manually
converts the output vector from SCS into their RCS form.
C. Results
Based on the manual computations obtained, there are a
total of 160 vector fields (including vectors whose values are
0) from the combination of all possible values in the set of r,
angle theta and angle phi, in test value. All possible
output vector were obtained by generating a MATLAB code
that would accept all sets of values for r, angle theta and
angle phi (Codes shown in Appendix).
In Fig.9, the point where most lines converge is the
origin. The vectors graphed at various points are the same
vectors, in RCS, generated by substituting the values given
by the user to the specified vector field.The further a vector
is to the origin, the larger the radius(r) is given. Still, all
vectors have the same magnitude for test value 1.

Fig. 9. Output vector trial 1 in 3D RCS generated using MATLAB

In Fig. 10, the top view shows the x and y axes of the
graph, where situated along the y-axis are vectors in a
seemingly straight line. These are the vectors whose Ax are 0
or whose angle phi values are 90 and 270.

Table4. Table used for converting RCS and SCS.

Ax

sincos

coscos

-sin

Ay

sinsin

cossin

cos

Az

cos

-sin

Using the built-in function quiver3 (x, y, z, Ax, Ay, Az),


this would plot all the output vector fields. Hold on code
was used so that all the possible combinations of vector field
shall be plotted.
The program created only allows the user to input vector
components in SCS form, altering the input components
leads to error in algorithm. Also, the input values must
follow strictly the format and arrangement in set [( ), (angle

Fig. 10. Output vector trial 1 in top view RCS generated using MATLAB

In Fig.11, the front view shows vectors along the YZ


plane where a number of vectors seem to form a straight line
along y = 0. These vectors have a value of Ay = 0, and are
defined by either angle theta or angle phi whose values are 0
and 180.

In Fig.13 (the analysis is same in Fig. 9), the point where


most lines converge is the origin. The vectors graphed at
various points are the same vectors, in RCS, generated by
substituting the values given by the user to the specified
vector field.The further a vector is to the origin, the larger the
radius(r) is given. Still, all vectors have the same magnitude
for test value 2.

Fig. 11. Output vector trial 1 in front view RCS generated using MATLAB

In Fig. 12, the right side view shows numerous vectors


with the same direction at z = 0, indicating that they have Az
= 0 value. These vectors are defined when angle theta values
are 90 and 270.

Fig. 13. Output vector trial 2 in 3D RCS generated using MATLAB

In Fig. 14, the top view shows the x and y axes of the
graph, where situated along the y-axis are vectors in a
seemingly straight line. These are the vectors whose Ax are
0 or whose angle phi values are 90 and 270

Fig. 12. Output vector trial 1 in right side view RCS generated using MATLAB

Based on the manual computations obtained, there are a


total of 164 vector fields from the combination of all possible
values in the set of r, angle theta and angle phi, in test value
2. All possible output vector were obtained by generating a
MATLAB code that would accept all sets of values for r,
angle theta and angle phi (Codes shown in Appendix).

Fig. 14. Output vector trial 2 top view RCS generated using MATLAB

In Fig.15, the front view shows vectors along the YZ


plane where a number of vectors seem to form a straight line
along y = 0. These vectors have a value of Ay = 0, and are
defined by either angle theta or angle phi whose values are 0
and 180.

Table 5 displays the values for inputting the vectors and


the desired output in CCS.
Table 5. Displays the values of sets for r, angle theta, angle phi and the
vector field given.
Input

= +
.

Trial 1

r= ( 0,1,2,3)
= ( 0,45,90,135,180)
= ( 0,45,90,135,180,225,270,315)

Trial 2

r= ( 0,1,2,3)
= ( 0,30,60,90,120,150,180)
= ( 0,60,120,180,240,300)

IV. DISTRIBUTION OF TASKS


John Ianne Miguel T.
Garcia
Fig. 15. Output vector trial 2 in front view RCS generated using MATLAB

In Fig. 16, the right side view shows numerous vectors


with the same direction at z = 0, indicating that they have
Az = 0 value. These vectors are defined when angle theta
values are 90 and 270.

Jasmin D. Raca

Limuel Z. Ruiz

- Constructed the algorithm and


code for problem 1 and 2
- Explained to the group how the
code works and interpreted the
output
-Compiled the zip file
- Wrote and edited the background
of the study, and discussion of
questions
- Proofread the paper for Machine
Problem 1
- Solved the test values manually
for problem 1
-Compiled all the work each
member has contributed
- Transformed the references into
their proper APA format
-Wrote the significance of
machine problem
- Constructed the Appendix

V. REFERENCES

Fig. 16. Output vector trial 2 in right side view RCS generated using
MATLAB

[1] Scalar Component of Vector. (n.d.).[Online]. Available:


http://www.tutorvista.com/physicss/scalar-component-of-vector
[2] Massachusetts Institute of Technology.(n.d.). Review A:
Vector Analysis [Online].Available: http://web.mit.edu/
8.02t/www/materials/modules/ ReviewA.pdf
[3] The Mathworks, Inc. (2015). MATLAB: The Language of
Technical Computing.[Online] .Available: http://www.mathworks.
com /products/matlab/
[4] The Mathworks, Inc. (2015). Vectorization. [Online].
Available: http://www.mathworks.com/help/matlab/matlab_prog
/vectorization.html?refresh=true

You might also like