Matlab-Vector Basics.pdf, Lecture notes of Engineering

magnitude. The direction can be described either through coordinates or angles. An easy example of a vector quantity is velocity of a car.

Typology: Lecture notes

2022/2023

Uploaded on 03/01/2023

dewan
dewan 🇺🇸

4.6

(17)

253 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Vector Operations and Matlab
The following is a supplementary source for reviewing and understanding the basic
concepts of vector manipulation as it relates to Statics. This review is engineering in
nature but will be presented in a more casual manner in hopes of clarifying and
simplifying the subject matter. For a more in-depth review, consult a Statics book.
What is a vector?
In the simplest terms, a vector is nothing more than a line with a specified direction and
magnitude. The direction can be described either through coordinates or angles. An
easy example of a vector quantity is velocity of a car. If you are driving 75 mph due
West then you just described a vector. If you are driving 75 mph on I-80 then you have
described a scalar because only magnitude is known, direction is not specified. A vector
can be written in many different ways. Depending on how you were taught, a vector may
be identified by either an arrow over the top of a character or a line below a character as
shown below:
Aor A
Figure 1. Vector Symbols
In this tutorial, vectors will be denoted by a line below their character.
The direction of a vector can be described in two main ways: a vector can be described
by an associated angle or through x-y-z components. The two systems for describing the
direction of a vector are compatible. If the x-y-z components are known then the angle
can be calculated and visa versa.
An often confusing concept for people new to working with vectors is the notation. In
introductory engineering classes, the axis are labeled x, y, and z. The vector directions
associated with the x, y, and z directions are i, j, and k. Why are the directions not x, y,
and z? Who knows?!?! The longer you are in engineering the more notation systems you
will learn. Each notation system has its place and will prove to be useful but will often
seem irrelevant and confusing until you reach more advanced engineering classes.
How to deal with vectors?
Working with vectors is not complicated. There are only a couple of tricks to remember.
1.) Vector addition and subtraction always occurs tip to tail. This means that when
adding vectors you align the vectors of interest so that the tail of one vector
touches the tip of the previous. The resultant vector is drawn from the tail of the
first vector to the tip of the last. Several examples are shown below.
pf3
pf4
pf5

Partial preview of the text

Download Matlab-Vector Basics.pdf and more Lecture notes Engineering in PDF only on Docsity!

Vector Operations and Matlab

The following is a supplementary source for reviewing and understanding the basic concepts of vector manipulation as it relates to Statics. This review is engineering in nature but will be presented in a more casual manner in hopes of clarifying and simplifying the subject matter. For a more in-depth review, consult a Statics book.

What is a vector?

In the simplest terms, a vector is nothing more than a line with a specified direction and magnitude. The direction can be described either through coordinates or angles. An easy example of a vector quantity is velocity of a car. If you are driving 75 mph due West then you just described a vector. If you are driving 75 mph on I-80 then you have described a scalar because only magnitude is known, direction is not specified. A vector can be written in many different ways. Depending on how you were taught, a vector may be identified by either an arrow over the top of a character or a line below a character as shown below:

A or A

Figure 1. Vector Symbols

In this tutorial, vectors will be denoted by a line below their character.

The direction of a vector can be described in two main ways: a vector can be described by an associated angle or through x-y-z components. The two systems for describing the direction of a vector are compatible. If the x-y-z components are known then the angle can be calculated and visa versa.

An often confusing concept for people new to working with vectors is the notation. In introductory engineering classes, the axis are labeled x, y, and z. The vector directions associated with the x, y, and z directions are i, j, and k. Why are the directions not x, y, and z? Who knows?!?! The longer you are in engineering the more notation systems you will learn. Each notation system has its place and will prove to be useful but will often seem irrelevant and confusing until you reach more advanced engineering classes.

How to deal with vectors?

Working with vectors is not complicated. There are only a couple of tricks to remember.

1.) Vector addition and subtraction always occurs tip to tail. This means that when adding vectors you align the vectors of interest so that the tail of one vector touches the tip of the previous. The resultant vector is drawn from the tail of the first vector to the tip of the last. Several examples are shown below.

Figure 2. Vector Addition

Figure 3. Vector Subtraction

Figure 4. Tip to Tail Visualization

2.) When adding or subtracting vectors, it is almost always easiest to break the vectors into their x-y-z components. This can be done through several methods but the most reliable and most convenient manner is through manipulation of trigonometric identities.

Figure 5. Complete Vector and Components

The vector A, shown in Figure 5, is easily broken down into its x and y components through the use of trigonometric identities and by knowing the magnitude, A, and the angle, . The x component, Ax , can be obtained by performing the following operations:

Likewise for Ay:

B

C

A + B = A

A B A B C

A B A B C

A

A (^) x

cos 

A (^) xA cos 

A

A (^) y sin 

A y  A sin 

Unit vectors are often denoted by a “^” symbol. Unit vectors are also often denoted by the notation, “n = unit vector.”

With the basic tools described above and an understanding of elementary math, vectors operations should be easily managed.

Example – MATLAB

The following code will walk you through how to use MATLAB to solve for the magnitudes and unit vectors of various vectors and how to subsequently add or subtract them.

%Vector Example clear all clc

%Our vectors of interest are the following: % Vector A: A=1i+2j+3k % Vector B: B=4i-5j+6k

%Defining each vector: A=[1 2 3] B=[4 -5 6]

%Defining the individual vector components Ai=A(1) Aj=A(2) Ak=A(3)

Bi=B(1) Bj=B(2) Bk=B(3)

%Finding the vector magnitudes: Mag_A=sqrt(Ai^2+Aj^2+Ak^2) Mag_B=sqrt(Bi^2+Bj^2+Bk^2)

%Defining the unit vectors: Unit_A=A/Mag_A Unit_B=B/Mag_B

%Adding the vectors: C=A+B

%or

Ci=Ai+Bi Cj=Aj+Bj Ck=Ak+Bk

C=[Ci Cj Ck]

Where the solutions to the above are:

  • A =
  • B = 4 -5
  • Ai =
  • Aj =
  • Ak =
  • Bi =
  • Bj = -
  • Bk =
  • Mag_A = 3.
  • Mag_B = 8.
  • Unit_A = 0.2673 0.5345 0.
  • Unit_B = 0.4558 -0.5698 0.
  • Ci = C = 5 -3 9 (Adding A+B=C)
  • Cj = -
  • Ck =