logo

MATLAB EXERCISES. LINEAR ALGEBRA

11 Pages2286 Words385 Views
   

Added on  2021-11-05

About This Document

LINEAR ALGEBRA clear; close all; clc; QUESTION 6 disp('---------------------------------------------------') disp('Question 6') %set #1 sa=[1,2,-1,0]; sb=[-3,-6,3,0]; sc=[-2,-2,1,-1]; disp('Question6: Set (a)') s1=[sa;sb;sc] %The first set % finding the subset that forms

MATLAB EXERCISES. LINEAR ALGEBRA

   Added on 2021-11-05

ShareRelated Documents
TABLE OF CONTENTS
QUESTION 6.........................................................................................................................................1
QUESTION 7.........................................................................................................................................2
QUESTION 8.........................................................................................................................................3
QUESTION 9.........................................................................................................................................7
QUESTION 10.......................................................................................................................................7
PRELIMINARY SECTION
... MATLAB EXERCISES
... LINEAR ALGEBRA
clear;
close all;
clc;
QUESTION 6
disp('-------------------------------------------------------------------')
disp('Question 6')
%set #1
sa=[1,2,-1,0];
sb=[-3,-6,3,0];
sc=[-2,-2,1,-1];
disp('Question6: Set (a)')
s1=[sa;sb;sc] %The first set
% finding the subset that forms a basis for the span of the vectors
R1=rref(s1) %determine the linearly independent vectors
disp('The vector that forms the basis for the span of the vectors: ')
v_span=R1(1,:)
%set #
sd=[0,0,1,1,0];
se=[1,1,0,0,1];
sf=[1,1,1,1,1];
sg=[1,1,2,2,1];
sh=[0,0,3,3,1];
sk=[0,0,0,0,1];
disp('Question6: Set (b)')
s2=[sd;se;sf;sg;sh;sk]
% finding the subset that forms a basis for the span of the vectors
R2=rref(s2)
disp('The vector that forms the basis for the span of the vectors: ')
v_span2=R2(3,:)
-------------------------------------------------------------------
Question 6
Question6: Set (a)
s1 =
1
MATLAB EXERCISES. LINEAR ALGEBRA_1
1 2 -1 0
-3 -6 3 0
-2 -2 1 -1
R1 =
1.0000 0 0 1.0000
0 1.0000 -0.5000 -0.5000
0 0 0 0
The vector that forms the basis for the span of the vectors:
v_span =
1 0 0 1
Question6: Set (b)
s2 =
0 0 1 1 0
1 1 0 0 1
1 1 1 1 1
1 1 2 2 1
0 0 3 3 1
0 0 0 0 1
R2 =
1 1 0 0 0
0 0 1 1 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
The vector that forms the basis for the span of the vectors:
v_span2 =
0 0 0 0 1
QUESTION 7
clear
A=[-1,2,0,0,3;0,2,3,-1,2;-1,4,3,-1,5;2,-4,0,0,-6;0,0,0,1,1];
A1=sym(A);
2
MATLAB EXERCISES. LINEAR ALGEBRA_2
disp('-------------------------------------------------------------------')
disp('Question 7')
%Basis for the row space A
w=rref(A)
%Basis for the column space A
B2=colspace(A1)
%finding the rank of A
B3=rank(A)
-------------------------------------------------------------------
Question 7
w =
1.0000 0 3.0000 0 0
0 1.0000 1.5000 0 1.5000
0 0 0 1.0000 1.0000
0 0 0 0 0
0 0 0 0 0

B2 =

[ 1, 0, 0]
[ 0, 1, 0]
[ 1, 1, 0]
[ -2, 0, 0]
[ 0, 0, 1]

B3 =
3
QUESTION 8
clear
disp('-------------------------------------------------------------------')
disp('Question 8')
A2=[1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16];
%finding the basis for the nullspace
A2a=sym(A2)
Z=null(A2a)
%verify the sum of the rank and nullity of A equals to
...number of columns
nullityofA2=size(Z,2)
verifyA2=A2*Z
3
MATLAB EXERCISES. LINEAR ALGEBRA_3
A3=hilb(5)
A3w=sym(A3)
%finding the basis for the nullspace
Z1=null(A3w)
%verify the sum of the rank and nullity of A equals to
...number of columns
nullityofA3=size(Z1,2)
verifyA3=A3*Z1 %should have an empty set full of null elements
A4=pascal(5)
%finding the basis for the nullspace
A4w=sym(A4)
Z2=null(A4w)
%verify the sum of the rank and nullity of A equals to
...number of columns
nullityofA4=size(Z2,2)
verifyA4=A4*Z2
A5=magic(6)
%finding the basis for the nullspace
A5w=sym(A5)
Z3=null(A5w)
%verify the sum of the rank and nullity of A equals to
...number of columns
nullityofA5=size(Z3,2)
verifyA5=A5*Z3
-------------------------------------------------------------------
Question 8

A2a =

[ 1, 2, 3, 4]
[ 5, 6, 7, 8]
[ 9, 10, 11, 12]
[ 13, 14, 15, 16]


Z =

[ 1, 2]
[ -2, -3]
[ 1, 0]
[ 0, 1]

nullityofA2 =
4
MATLAB EXERCISES. LINEAR ALGEBRA_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Linear Algebra Questions and Solutions
|10
|2154
|216