Linear algebra matlab questions


This project is to be done with MATLAB, and you should hand in your printed output during class. Use

the “diary” command to save your work in a (text) file (make your life easy and give the file an

informative name). If you are familiar with the publish command, you can use it to generate your file.


Edit the saved file to include your name, the problem numbers, and the answers to any questions asked in

the problems, and delete the mistakes/syntax errors/. Then print your file and turn it in during

discussion, on or before the due date.


You can form groups of 2-3 students from your TA’s sections to complete each MATLAB project; if you

did so, include in your submission the names of those students with whom you collaborated.

A few general comments (inspired by Prof. Boyle). With the idea that you only learn by doing, everyone

in the group must still hand in a MATLAB project. These are not to be copied files — everyone should do

the keyboard work, which is a big part of getting comfortable with using MATLAB. You might work

together with your laptops or in a lab. One approach is to work out your assignments side by side on

different computers, discussing the commands needed.

If you copy from the result of a joint effort, please explain the work/results in your own words. If you

copy without working on the project, then you are cheating. For a given group, your TA will choose one

group member’s project, grade it, and give everyone in the group that grade.

For access to MATLAB, you can download your own educational version (now for free, see, use one of the OWL labs or the computers in the

library, or to run it from the Engineering Department’s Virtual Lab ( ).


MATLAB tutoring is available in the Mathematics building, room 0203 lab, see more details at

Whenever you use a new MATLAB command learn about it by using the “help” command; e.g.,

type “help rref” to learn about the rref command. When you want to look for a command but you

don’t know its exact name ‘lookfor’ might be helpful. And of course help-> product help is a great

window to have opened when trying to figure out syntax for a command.

GENERAL Comment: If this is the first time you are using MATLAB, you may want to watch before

attempting the project the demos Basic Matrix Operations, Matrix Manipulation, Controlling Random

Number Generation and also the videos Getting Started with MATLAB (5 min, 18 sec), Publishing Code

from the Editor (5 min, 15 sec) (all found in Help-> MATLAB->Demos)





Page 2 of 3

MATH240 MATLAB PROJECT 1: Due March 1 st 2016

The goals of this project are: (1) to be able to input by hand and use MATLAB functions to generate

vectors and matrices in MATLAB; (2) to use MATLAB to generate a reduced echelon form for a matrix;

(3) to solve a system using the reduced echelon form of its augmented matrix; (4) to investigate the linear

dependence of a set of vectors.

PROBLEM 1: a) Generate A a 5×4 matrix based on five historical dates you consider important. (Input

this by hand; for example, if Time Travelling Terp was planning to use the birthdate of Gabriel Cramer of

Cramer’s rule fame, 31 July 1704, its matrix A will have a row or column containing the numbers 31, 07

,17, 04.

b) Using MATLAB functions, generate B, a 5×4 matrix of ones,O a 5×4 matrix of zeroes and I, the 4×4

identity matrix. Hint: To generate B, O, and I, search for help on the functions zeroes, ones, eye.

PROBLEM 2: Based on the matrices in problem 1, compute the following elements and then explain

what they are in the corresponding matrix:

(a) a=A(2,4) ; (i.e. this is the ____ element/row/column of the matrix A)

(b) ac= A(:,4);

(c) ar= A(2,:).

Is it true or false that (d) a*B=B*a and (e) ac*I=I*ac? (here * stands for multiplication; if a side of an

equality cannot be computed, the equality is false).

Explain your results for Problem 2 points (d) and (e ).

PROBLEM 3: (a) Generate a random 3×5 matrix 𝐴 with entry integers uniformly between -100 and 100.

Hint: Search for help on the functions rand and randi. (b) Put the matrix 𝐴 in reduced echelon form

using the command rref. (c) Are the columns of A linearly independent? Why or why not? (d) What is

the span of the columns of A? Base your answer on your result at points 3b and your general knowledge

of what the Span of 1, 2, 3,4 linearly independent vectors should be.

PROBLEM 4: Water is flowing through a network of pipes (in thousands of cubic meters per hour) as

shown in the figure below.






𝑥1 𝑥2

𝑥5 𝑥4 𝑥3

𝑥6 𝑥7 6000







Page 3 of 3

(a) Set-up in MATLAB a matrix equation whose solution determines the water flow represented by

𝑥𝑖, 𝑖 = 1,2,⋯ , 7. Hint: to determine what system you are trying to solve, please remember that ‘Volume

in=Volume out”, so for example the equation corresponding to the leftmost, top node is: 600 = 𝑥1 + 𝑥3;

(b) State what the rows and columns in the matrix represent;

(c) Based on the number of the equations and the number of unknowns, do you expect that the equation at

point (a) has no solutions, exactly one solution or an infinity of solutions?

(d) Solve the equation and discuss your answer;

(e) Find the water flow (a vector containing values for all 𝑥𝑖 , 𝑖 = 1,2,⋯ , 7) when 𝑥5 = 1000 and 𝑥6 = 0.


PROBLEM 5: a) Using commands such as figure, ezplot and hold graph the lines representing each

equation in the system { −3𝑥 − 𝑦 = 3 6𝑥 + 2𝑦 = 1


b) Use the graph to determine whether the system is consistent or inconsistent;

c) If the system is consistent, approximate from the graph the solution;

d) Solve the system algebraically, using MATLAB to help you, and compare your algebraic result with

the approximation in part c);

e) Repeat problem 5 parts a-d for the system { 2𝑥 − 8𝑦 = 3 0.5𝑥 + 𝑦 = 0

Needs help with similar assignment?

We are available 24x7 to deliver the best services and assignment ready within 3-4 hours? Order a custom-written, plagiarism-free paper

Get Answer Over WhatsApp Order Paper Now