function RETURN=rswap(matrix,a,b) global noprint global err if(exist('matrix')==0) %check if passed matrix is defined noprint=1; sprintf('%s\n','The matrix you have passed as an argument to ROWOP has not been defined.') error(' ') end global undo; undo=matrix; mistake=0; sizecheck=size(matrix); if (a>sizecheck(1,1)) sprintf('%s\n%s','The first row index you entered exceeds the number of','rows in the given matrix') mistake=1; err=1; end if (b>sizecheck(1,1)) sprintf('%s\n%s','The second row index you entered exceeds the number of','rows in the given matrix') mistake=1; err=1; end if(mistake>0) error(' ') end tempa=matrix(a,:); tempb=matrix(b,:); matrix(a,:)=tempb; matrix(b,:)=tempa; RETURN=matrix;