quadrant 2 will be the original matrix with each row reversed in matlab

To reverse each row in quadrant 2 of a matrix in Matlab, you can use the fliplr function which flips the order of the elements in a row.

Assuming your matrix is called "originalMatrix", you can use the following code:

main.m
% get the size of the matrix
[numRows, numCols] = size(originalMatrix);

% get the midpoint of the rows and columns
midRow = floor(numRows / 2);
midCol = floor(numCols / 2);

% extract quadrant 2 of the matrix
quadrant2 = originalMatrix(1:midRow, midCol+1:end);

% reverse each row in quadrant 2
for i = 1:midRow
    quadrant2(i,:) = fliplr(quadrant2(i,:));
end

% assign the reversed quadrant 2 back to the original matrix
originalMatrix(1:midRow, midCol+1:end) = quadrant2;
476 chars
18 lines

This code first extracts quadrant 2 of the matrix by taking the first half of the rows and the second half of the columns. It then uses a for loop to reverse each row in quadrant 2 using the fliplr function. Finally, the reversed quadrant 2 is reassigned back to the original matrix.

gistlibby LogSnag