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
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...
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
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY