<< Chapter < Page Chapter >> Page >

Declaration of a column vector

Elements of a column vector is ended by a semicolon:

c = [1;2;3;4;5;]

Example3
Assignment of a column vector quantity.

Or by transposing a row vector with the ' operator:

c = [1 2 3 4 5]'

Example3a
Assignment of a column vector quantity by transposing a row vector with the ' operator.

Or by using the Variable Editor:

Example3b
Assignment of a column vector quantity by using the Variable Editor.

Declaration of a matrix

Matrices are typed in rows first and separated by semicolons to create columns. Consider the examples below:

Let us type in a 2x5 matrix:

d = [2 4 6 8 10; 1 3 5 7 9]

Example4
Assignment of a 2x5 matrix.

Example4a
Assignment of a matrix by using the Variable Editor.

This example is a 5x2 matrix:

example4b
Assignment of a 5x2 matrix.

Linear equations

Systems of linear equations are very important in engineering studies. In the course of solving a problem, we often reduce the problem to simultaneous equations from which the results are obtained. As you learned earlier, MATLAB stands for Matrix Laboratory and has features to handle matrices. Using the coefficients of simultaneous linear equations, a matrix can be formed to solve a set of simultaneous equations.

Let's solve the following simultaneous equations:

x y 1
2 x 5 y 9

First, we will create a matrix for the left-hand side of the equation using the coefficients, namely 1 and 1 for the first and 2 and -5 for the second. The matrix looks like this:

1 1 2 5

The above matrix can be entered in the command window by typing A=[1 1; 2 -5] .

Second, we create a column vector to represent the right-hand side of the equation as follows:

1 9

The above column vector can be entered in the command window by typing B= [1;9] .

To solve the simultaneous equation, we will use the left division operator and issue the following command: C=A\B . These three steps are illustrated below:

>>A=[1 1; 2 -5] A =1 1 2 -5>>B= [1;9] B =1 9>>C=A\B C =2 -1>>

The result C indicating 2 and 1 are the values for x and y , respectively.

Polynomials

In the preceding section, we briefly learned about how to use MATLAB to solve linear equations. Equally important in engineering problem solving is the application of polynomials. Polynomials are functions that are built by simply adding together (or subtracting) some power functions. (see Wikipedia ).

a x 2 b x c 0
f(x) a x 2 b x c

The coeffcients of a polynominal are entered as a row vector beginning with the highest power and including the ones that are equal to 0.

Create a row vector for the following function: y 2 x 4 3 x 3 5 x 2 x 10

Notice that in this example we have 5 terms in the function and therefore the row vector will contain 5 elements. p=[2 3 5 1 10]

Create a row vector for the following function: y 3 x 4 4 x 2 5

In this example, coefficients for the terms involving power of 3 and 1 are 0. The row vector still contains 5 elements as in the previous example but this time we will enter two zeros for the coefficients with power of 3 and 1: p=[3 0 4 0 -5] .

The polyval Function

We can evaluate a polynomial p for a given value of x using the syntax polyval(p,x) where p contains the coefficients of polynomial and x is the given number.

Questions & Answers

A golfer on a fairway is 70 m away from the green, which sits below the level of the fairway by 20 m. If the golfer hits the ball at an angle of 40° with an initial speed of 20 m/s, how close to the green does she come?
Aislinn Reply
cm
tijani
what is titration
John Reply
what is physics
Siyaka Reply
A mouse of mass 200 g falls 100 m down a vertical mine shaft and lands at the bottom with a speed of 8.0 m/s. During its fall, how much work is done on the mouse by air resistance
Jude Reply
Can you compute that for me. Ty
Jude
what is the dimension formula of energy?
David Reply
what is viscosity?
David
what is inorganic
emma Reply
what is chemistry
Youesf Reply
what is inorganic
emma
Chemistry is a branch of science that deals with the study of matter,it composition,it structure and the changes it undergoes
Adjei
please, I'm a physics student and I need help in physics
Adjanou
chemistry could also be understood like the sexual attraction/repulsion of the male and female elements. the reaction varies depending on the energy differences of each given gender. + masculine -female.
Pedro
A ball is thrown straight up.it passes a 2.0m high window 7.50 m off the ground on it path up and takes 1.30 s to go past the window.what was the ball initial velocity
Krampah Reply
2. A sled plus passenger with total mass 50 kg is pulled 20 m across the snow (0.20) at constant velocity by a force directed 25° above the horizontal. Calculate (a) the work of the applied force, (b) the work of friction, and (c) the total work.
Sahid Reply
you have been hired as an espert witness in a court case involving an automobile accident. the accident involved car A of mass 1500kg which crashed into stationary car B of mass 1100kg. the driver of car A applied his brakes 15 m before he skidded and crashed into car B. after the collision, car A s
Samuel Reply
can someone explain to me, an ignorant high school student, why the trend of the graph doesn't follow the fact that the higher frequency a sound wave is, the more power it is, hence, making me think the phons output would follow this general trend?
Joseph Reply
Nevermind i just realied that the graph is the phons output for a person with normal hearing and not just the phons output of the sound waves power, I should read the entire thing next time
Joseph
Follow up question, does anyone know where I can find a graph that accuretly depicts the actual relative "power" output of sound over its frequency instead of just humans hearing
Joseph
"Generation of electrical energy from sound energy | IEEE Conference Publication | IEEE Xplore" ***ieeexplore.ieee.org/document/7150687?reload=true
Ryan
what's motion
Maurice Reply
what are the types of wave
Maurice
answer
Magreth
progressive wave
Magreth
hello friend how are you
Muhammad Reply
fine, how about you?
Mohammed
hi
Mujahid
A string is 3.00 m long with a mass of 5.00 g. The string is held taut with a tension of 500.00 N applied to the string. A pulse is sent down the string. How long does it take the pulse to travel the 3.00 m of the string?
yasuo Reply
Who can show me the full solution in this problem?
Reofrir Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, A brief introduction to engineering computation with matlab. OpenStax CNX. Nov 17, 2015 Download for free at http://legacy.cnx.org/content/col11371/1.11
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'A brief introduction to engineering computation with matlab' conversation and receive update notifications?

Ask