Lab 6
Lab 6
ECEM 0313
Laboratory Activity No. 6
Vectors, Vector Spaces, Matrices,
And Linear Systems
Score
disp('Row Echelon')
x=1;
while x~=2
scalar=input('Enter scalar value for matrix 1 if none=');
rows=input('Enter the number of rows for matrix=');
columns=input('Enter the number of columns for matrix=');
size=ones(rows,columns);
disp(size)
values=input('EnterValues inside''[]'' and add '';'' for the
next row=');
values=scalr.*values;
[L,Row_Echelon_Form]=lu(values);
x=1;
while x<=rows
Row_Echelon_Form(x,:)=Row_Echelon_Form(x,:)./Row_Echelon_Form(x,x);
x=x+1;
end
Final_Answer=rref(Row_Echelon_Form);
disp(values)
disp(Row_Echelon_Form)
disp(Final_Answer(:,end))
x=input('Solve for another matrix?\n(1)Yes (2)No\n');
end
elseif options==8
disp('Matrix Inverses')
x=1;
while x~=2
scalar=input('Enter scalar value for matrix, 1 if none=');
rows=input('Enter the number of rows for 1st matrix=');
columns=input('Enter the number of columns for 1st matrix=');
size = ones(rows,columns);
disp(size)
values=input('put values inside''[]'' and add '';'' for the next
row=');
values=scalar.*values;
Inverse=inv(values);
disp(Inverse)
x=input('Solve for another matrix?\n(1)Yes (2)No\n');
end
elseif options==9
disp('LU Factorization of matrixes')
scalar=input('Enter scalar value for matrix, 1 if none=');
rows=input('Enter the number of rows for 1st matrix=');
columns=input('Enter the number of columns for 1st matrix=');
size = ones(rows,columns);
disp(size)
values=input('Enter values inside''[]'' and add '';'' for the next
row=');
values=scalar.*values;
[L,U]=lu(values);
option=input('Is there a value after the equal sign of the linear
equation or matrix?\n(1)Yes (2)No');
if option==1
B=input('Enter values after the equal sign of the equation or other
matrix inside''[]'' and add '';'' for the next row=');
L=[L B];
rl=rref(L);
U=[U rl(:,end)];
ru=rref(U);
L(:,end)=[];
U(:,end)=[];
disp(L([4 1 3 2],:))
disp(U)
disp(ru)
else
disp(L([4 1 3 2],:))
disp
end
elseif options==10
disp('Determinants of a matrix: (Must be a square Matrix)')
x=1;
while x~=2
scalar=input('Enter scalar value for matrix, 1 if none=');
rows=input('Enter the number of rows for 1st matrix=');
columns=input('Enter the number of columns for 1st matrix=');
size = ones(rows,columns);
disp(size)
values=input('Enter values inside''[]'' and add '';'' for the
next row=');
values=scalar.*values;
Determinant=det(values);
disp(Determinant)
x=input('Solve for another matrix?\n(1)Yes (2)No\n');
end
else
disp('None of the choices')
end