[Solved] Math551 Lab 2

$25

File Name: Math551_Lab_2.zip
File Size: 122.46 KB

SKU: [Solved] Math551 Lab 2 Category: Tag:
5/5 - (1 vote)

Goals: In this assignment you will learn how to determine whether a system of linear equations has a solution, how to reduce a system to a row echelon form and how to visualize the solution. During the lab session, your lab instructor will teach you the necessary Matlab code to complete the assignment, which will be discussed in the lab.

To get started: Create a new Matlab script file and save it as lab02.m.

Matlab commands to learn: magic, rref, rank, transpose, plot, figure, hold on, grid on, grid off, subplot, meshgrid, surf, view

What you have to submit: The file lab02.m, which you will create during the lab session.

Reminders About the Grading Software

Remember, the labs are graded with the help of software tools. If you do not follow the instructions, you will lose points. If the instructions ask you to assign a value to a variable, you must use the variable name given in the instructions. If the instructions ask you to make a variable named x1 and instead you make a variable named x or X or X1 or any name other than x1, the grading software will not find your variable and you will lose points. Required variables are listed in the lab instructions in a gray box like this:

Variables: x1, A, q

At times you will also be asked to answer questions in a comment in your M-file. You must format your text answers correctly. Questions that you must answer are shown in gray boxes in the lab. For example, if you see the instruction

Q7: What does the Matlab command lu do? your file must contain a line similar to the following somewhere

% Q7: It computes the LU decomposition of a matrix.

The important points about the formatting are

  • The answer is on a single line.
  • The first characters on the line is the comment character %.
  • The answer is labeled in the form Qn:, where n stands for the question number from the gray box.

If you do not format your answers correctly, the grading software will not find them and you will lose points.

TASKS

  1. Create a 5 5 matrix A using the magic command. Type help magic in the command line to learn about the magic command.

Variables: A

  1. Create a column-vector B with entries 1,3,2,1, Variables: B
  2. Create a matrix M by adding the vector B as the last column of the matrix A. Variables: M
  3. Check the rank of A and M using the rank Type help rank in the command line to learn about the rank command.
Variables: rank A, rank M
Q1: Is the system with augmented matrix M consistent?
  1. Produce a reduced row echelon form of M by using the rref Type help rref in the command line to learn about the rref command. Variables: rref M
  2. Create a 7 7 matrix C using the rand Type help rand in the command line to learn about the rand command. Variables: C
  3. Create a row vector D with 7 elements using the rand Variables: D
  4. Apply the transpose command to D. Type help transpose in the command line to learn about the transpose
Variables: transpose D
Q2: What does the transpose command do?
  1. Create an augmented matrix N of the system with coefficient matrix C and right-hand side D. Variables: N
  2. Apply the rref command to N.

Variables: rref N

  1. Consider the system of two equations:

( x + 2y = 3 x y = 0

Plot the lines representing each of the equations on one graph using the plot command on the interval [0,5]. Use the color red for the first equation and the color blue for the second.

Type in the commands

1 figure;
2 x = [0:0.1:5];
3 y1=(3-x)/2;
4 y2=x;
5 plot(x,y1,red);
6 hold on;
7 plot(x,y2,blue);
8 grid on;
  1. Consider the system

2x + y + z = 4

x + y z = 1

3x + 2y z = 6

Note that this system of equations cooresponds to the following augmented matrix:

Type in the commands

1 figure;
2 [x,y]=meshgrid(-5:0.1:5,-5:0.1:5);
3 z1=4-2*x-y;
4 z2=-x+y-1;
5 z3=3*x+2*y-6;
6 surf(x,y,z1);
7 hold on;
8 surf(x,y,z2);
9 hold on;
10 surf(x,y,z3);
Q8: What does the meshgrid command do?
Q9: What does the surf command do?
  1. Come up with three systems of linear equations in three variables (with three equations each) representing all possible situations: no solution, a unique solution, infinitely many solutions. For each system of equations, create the corresponding augmented matrix, respectively naming them no sol, uni sol, inf sol. Apply the commands above to produce a visual picture for each of the systems (each on a separate figure). Use appropriate limits for variables x and y and a command view to present each case clearly.

Variables: no sol, uni sol, inf sol

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Math551 Lab 2
$25