Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise, you will be given two matrices A and B. You will write a set of commands in MATLAB that will determine whether

In this exercise, you will be given two matrices A and B. You will write a set of commands in MATLAB that will determine whether the Col A and Col B are subspaces of the same space . If yes, your code has to determine if dim ColA = dim ColB and, finally, whether Col A = Col B. (Obviously, when two subspaces have the same dimension, it might not be true that they are the same set. For example, a line through the origin in is a one dimensional subspace of but two lines might be different sets the sets are equal if they have the same elements.) Use MATLAB function rank within your code. Remember, the rank of a matrix can be defined as the dimension of the column space of the matrix.

INSTRUCTIONS: **In MATLAB, create

function [ ] = subspace(A,B)

Begin the function with comparing the numbers of rows in matrices A and B. If the numbers of rows are different, Col A and Col B are subspaces of different spaces and cannot be equal the program terminates (the command return terminates the program). A possible code for this part with an output message is:

m=size(A,1);

n=size(B,1);

if m ~ = n

disp(Col A and Col B are subspaces of different spaces)

return

else

fprintf(Col A and Col B are subspaces of R^ % i \ n, m)

end

(Note: n in % i\ n has nothing to do with size(B,1) it is a part of the syntax for the command fprintf.)

If Col A and Col B are subspaces of the same space, the program will continue:

You will calculate the dimensions of Col A and Col B which should be k and l, respectively, and display them in your message. (I suggest using fprintf command.).

Next, you will compare k and l and, if they are equal, you should decide if Col A = Col B. In order to verify whether the column spaces are the same, we want to know whether the columns of B are in Col A and the columns of A are in Col B. To determine that, we can compare the common value of k and l with the rank of a certain matrix that you will create using matrices A and B. After the comparison is made in your code, the output will be one of the three possible messages:

k ~ = l, the dimensions of Col A and Col B are different,

k = l, the dimensions of Col A and Col B are the same, but Col A ~ = Col B,

or

Col A = Col B.

Finally, you will compare k and l with m and return messages that will specify whether Col A and Col B are all for the corresponding m or not. An example of the code of one of the four possible output messages is:

fprintf(k = m (% i = % i) Col A is all R^% i \ n, k, m, m)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions