Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Computational Methods- Matlab Question Create a function that inputs [A] and b m

ID: 641401 • Letter: C

Question

Computational Methods- Matlab Question

Create a function that inputs [A] and b matrices, such that [A]x=b, and produces the echelon form of [U] (meaning all the components of the [A] matrix in the lower triangle are zero) and y.

Your code MUST CONTAIN for loops.

YOU MUST NOT use the built in Matlab function "ref".

Any help from Matlab gurus? Would appreciate a well commented answer! Thank you

Explanation / Answer

% The function: toRREF(matrix, epsilon) % % Inputs: % + matrix: an m x n matrix. % + epsilon: a positive real number. Any number x such that 0 abs(echelon(maxChosen, lead)) maxChosen = curRow; end end if isZero(echelon(maxChosen, lead), epsilon) % All entries we consider so far are zero maxChosen = row; lead = lead + 1; if lead > numCol return; end else flagStop = 1; end end %while isZero(echelon(maxChosen, lead), epsilon) % maxChosen = maxChosen + 1; % if maxChosen > numRow % maxChosen = row; % lead = lead + 1; % if lead > numCol % return; % end % end %end disp(maxChosen) disp(lead) if maxChosen ~= row % Swap the two rows tempRow = echelon(row, :); echelon(row, :) = echelon(maxChosen, :); echelon(maxChosen, :) = tempRow; end disp(echelon) if ~isZero(echelon(row, lead), epsilon) echelon(row, :) = echelon(row, :) / echelon(row, lead); end for curRow = 1 : numRow if curRow ~= row echelon(curRow, :) = echelon(curRow, :) - echelon(curRow, lead) * echelon(row, :); end end disp(echelon) lead = lead + 1; end end function result = isZero(num, epsilon) result = abs(num)
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote