Pivoting a matrix using largest magnitude coefficent and diagonal values
28 ビュー (過去 30 日間)
I have a question for an assignment asking this
c. Write a function in MATLAB (rowpivot.m) that performs pivoting on a matrix (determines the location of the largest magnitude coefficient at or below the specified diagonal value and swaps the rows as necessary). The function will work for any location along the diagonal 1 through n). This function will call rowswap.m written in part (a) as necessary. Verify that the function works by pivoting on the original matrix in part (a) for the second element along the diagonal.
I did the other parts but i am alittle confused on what to do with this. The code I have for it is below
would this be the correct way to get the diagonal value and swap the required rows.
Rest of the code is below if that helps
%this is the main script of the program
%Sets the matrix paramaters
Matrix=[1 7 -4 3 -3; 0 3 1 -2 2;0 4 3 4 5; 0 -5 8 1 3];
%Commands for rowswap
fprintf('The following matrix has had its rows swapped\n');
%commands for row reduction
fprintf('The following matrix has had its rows reduxed\n')
%Commands for row pivot
fprintf('The following matrix has had its rows pivoted\n')