程序代写代做代考 ENG 6, Spring 2016 Lab 5 Linear Algebra

ENG 6, Spring 2016 Lab 5 Linear Algebra

Problem 1

1) Create a function, name it Lab5.m
 The input of the function should be (A, B), where A is a 2-by-2 matrix, and B is a two-

element column vector.

 The output of the function is X
 The function should satisfy the below requirements:

 Imagine
a b

A
c d

 
  
 

, and
e

B
f

 
  
 

 The function should solve the system of equations

bx ay e

dx cy f

 

 

If there is no solution, or there are multiple solutions, the function returns

X=empty array (i.e. X=[]), and display “cannot solve”

If there is only one solution, the function returns the solution by a column vector

X where

x
X

y

 
  
 

NOTE: any other invalid input (such as giving A as 3-by-3 matrix) will be avoided during

test, so don’t worry about the invalid input.

2) Test your function
Write a script, let:

A1 = [3 1; 1 6]; B1 = [9; 20];

A2 = [3 1; 6 2]; B2 = [9; 18];

A3 = [3 1; 6 2]; B3 = [9; 20];

Call your function using Lab5(A1, B1), Lab5(A2, B2), Lab5(A3, B3), respectively.

Display the calculated result.

Submit three files:

 The function file

 The script file

 PDF file published from the script

Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *