Can you please correct my code? The correct output is on the left, while my output is on the right. Can you fix what I did wrong? Thank you.  this is my code:  A = [2 1 0;-1 1 1;1 1 -1] [ss,li,bas] = splibas(A)   function [ss,li,bas] = splibas(A)   % Initialize outputs to false ss = false; li = false; bas = false;   % Get Dimension of vectors dim = size(A(:,1),1);   % Get number of vectors n = size(A,2);   % Calculate Rank of A r= rank(A);   % If rank is equal to number of vector % Vectors are linearly independent if(r==n) li = true; end   % Calculate row echelon form of A RE = rref(A);   % Find number of non-zero rows span = 0; for i=1:dim if(~isequal(RE(i,:),zeros(1,n))) span = span + 1; end end   % If number of non-zero rows equals vector dimension % Vectors form a spanning set if(span==dim) ss = true; end   % If vectors are both spanning set and linearly-independent % They form Basis if(ss==true && li==true) bas = true; end   end

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Can you please correct my code? The correct output is on the left, while my output is on the right. Can you fix what I did wrong? Thank you. 

this is my code: 

A = [2 1 0;-1 1 1;1 1 -1]
[ss,li,bas] = splibas(A)

 
function [ss,li,bas] = splibas(A)

 
% Initialize outputs to false
ss = false;
li = false;
bas = false;

 
% Get Dimension of vectors
dim = size(A(:,1),1);

 
% Get number of vectors
n = size(A,2);

 
% Calculate Rank of A
r= rank(A);

 
% If rank is equal to number of vector
% Vectors are linearly independent
if(r==n)
li = true;
end

 
% Calculate row echelon form of A
RE = rref(A);

 
% Find number of non-zero rows
span = 0;
for i=1:dim
if(~isequal(RE(i,:),zeros(1,n)))
span = span + 1;
end
end

 
% If number of non-zero rows equals vector dimension
% Vectors form a spanning set
if(span==dim)
ss = true;
end

 
% If vectors are both spanning set and linearly-independent
% They form Basis
if(ss==true && li==true)
bas = true;
end

 
end
Output
A
OUTPUT:-
2
1
-1
1
1
1
1
-1
A= 3x3
1
SS =
-1
1
1
-1
logical
55 - Logical
1
1
li - Logical
li =
1
logical
bas = Logical
1
1
bas =
%3D
logical
1
Transcribed Image Text:Output A OUTPUT:- 2 1 -1 1 1 1 1 -1 A= 3x3 1 SS = -1 1 1 -1 logical 55 - Logical 1 1 li - Logical li = 1 logical bas = Logical 1 1 bas = %3D logical 1
BASIS of Vectors
My Sululona
Aghen l of vedurs ad lo fuma b he sl of vedors a both inearly indepandert and lama a aponning sa kar the givwn spce. In lh onn, he omera s
okad lo delemir wtwiher th nnaled veciora spanning sl, liaty duparderi and luma baot.
1. Couale a fundian with thrue oupul ja, Laaj wtach wil clamine whaltar the veckans s spanning sl, Iaty incapandeni snd lamaa bots lar e'n
2 Ihe ram ol he luncnt
3 Ihe furdian opia he corcalarudad vedor A and he progem wil solvw he sedud raw wdhein ferm hrum wtach ihe apretaton wil be doe utuhar h vedors are
Iaty mdaparderi, apanning sal and loemng a baeda for en
Function e
Save
|MAILAB Documenlalen
SThis program accepts the concatenated colunn vectors A, where the xiae ot the Matrix sill initially be checked. It will be transtormed inta its
Sreduced row echelan farn tran which the program shall interpret whether st tarms a basis, is linearly independent ar spanning set tor R"n.
Code to call your function e
A- 121 0;-1 1 1;1 1 -1]
(,11, bas]- plihan(A)
tunction (s, 11,bas]- splihan(A)
S Initialize autputs to talae
taise
11- taie
ban- tale;
S Cet Dimensian ot vectars
din- size(:,1),1);
S Cat number ot vectors
n stae(A, 2);
S Caleulate tank ot A
rank(A):
S It rank is mqual to runber at vector
S Vectors are linearly independent
11 true
end
S Calculate ra echelon torm at A
RE- Pret(A)
s rind nunber at nan-era re
span- e;
tor ii:din
xpanspan 1;
and
end
S It number ot non-zero ro quals vector dimension
S Vecters ferma spaning set
It(spandin)
true
end
S It vectars are bath spanning sat and linmarly-independent
S They tam Basis
it(Ertrue litrue)
bas true:
end
end
Transcribed Image Text:BASIS of Vectors My Sululona Aghen l of vedurs ad lo fuma b he sl of vedors a both inearly indepandert and lama a aponning sa kar the givwn spce. In lh onn, he omera s okad lo delemir wtwiher th nnaled veciora spanning sl, liaty duparderi and luma baot. 1. Couale a fundian with thrue oupul ja, Laaj wtach wil clamine whaltar the veckans s spanning sl, Iaty incapandeni snd lamaa bots lar e'n 2 Ihe ram ol he luncnt 3 Ihe furdian opia he corcalarudad vedor A and he progem wil solvw he sedud raw wdhein ferm hrum wtach ihe apretaton wil be doe utuhar h vedors are Iaty mdaparderi, apanning sal and loemng a baeda for en Function e Save |MAILAB Documenlalen SThis program accepts the concatenated colunn vectors A, where the xiae ot the Matrix sill initially be checked. It will be transtormed inta its Sreduced row echelan farn tran which the program shall interpret whether st tarms a basis, is linearly independent ar spanning set tor R"n. Code to call your function e A- 121 0;-1 1 1;1 1 -1] (,11, bas]- plihan(A) tunction (s, 11,bas]- splihan(A) S Initialize autputs to talae taise 11- taie ban- tale; S Cet Dimensian ot vectars din- size(:,1),1); S Cat number ot vectors n stae(A, 2); S Caleulate tank ot A rank(A): S It rank is mqual to runber at vector S Vectors are linearly independent 11 true end S Calculate ra echelon torm at A RE- Pret(A) s rind nunber at nan-era re span- e; tor ii:din xpanspan 1; and end S It number ot non-zero ro quals vector dimension S Vecters ferma spaning set It(spandin) true end S It vectars are bath spanning sat and linmarly-independent S They tam Basis it(Ertrue litrue) bas true: end end
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY