Thanks 1. 5 Points Write a function with the header m, U, xmysweep (A,b) which p
ID: 3736347 • Letter: T
Question
Thanks 1. 5 Points Write a function with the header m, U, xmysweep (A,b) which performs systematic linear transformation on the system Ax-b (the forward sweep). Note that this function should return not only the transformed A and b, but also a matrix n containing -m(, j) used in the transformation but also with I's on its diagonal. Recall that mli, j)A (i, 3) / A(j, j Since m will only populate with elements below the diagonal, you should first initialize m with mn zeros Teat Casca: format short >A[815 98 158 142 656 906 279 971 422 36i 127 547 958 916 850 914 958 486 793 934 633 965 801 960 6791 b (5333 6245: 12009; 12130; 12201) 1.0000 .0000 0.1558 3.128.0 1.1215 4.9871 0.7767 5.2270 2.2395 0 1.0000 2.3545 1.0000 .8098 1. 0000Explanation / Answer
Solution:
code:
function [X,y,i] = mySweep(X,y)
Xy = [X y];
i = zeros(length(X));
for n = 1:length(X)-1
for m = n+1:length(X)
i(m, n) = -(Xy(m, m)/Xy(n, n));
Xy(m,:) = Xy(m,:)+(Xy(n, :)*i(m, n));
end
end
y = Xy(:,end);
X = Xy(:,1:end-1);
Xy
end
Output:
>> mySweep(13, 8)
Xy =
13 8
ans =
13
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.