[Submit on zyLabs] Please write a function with one input, a matrix, and one output, a matrix of the same size. The output matrix should be the input matrix mirrored on the vertical axis. For instance, theinput:[123456789]Would become: [321654987]And the input:[112221112212]Would become:[221112221121]Note that this functions slightly differently for inputs with odd and even numbers of columns. For an odd number of columns, your centermost column stays the same. For an even number of columns, all columns are moved in the resulting output. You can use the function[yDim, xDim]

Respuesta :

Answer:

See explaination for the details.

Explanation:

% Matlab file calculateMirrorMatrix.m

% Matlab function to return a matrix which should be input matrix mirrored

% on the vertical axis

% input is a matrix

% output is a matrix of same size as input matrix

function [mirrorMatrix] = calculateMirrorMatrix(inputMatrix)

mirrorMatrix = zeros(size(inputMatrix)); % create output matrix mirrorMatrix of same size as inputMatrix

fprintf('\n Input Matrix :\n');

disp(inputMatrix); % display the input matrix

[row,col] = size(inputMatrix); % row, col contains number of rows and columns of the inputMatrix

% loop to find the matrix which should be input matrix mirrored

for i = 1:row

mirrorIndex =1;

for j = col:-1:1

mirrorMatrix(i,mirrorIndex)=inputMatrix(i,j);

mirrorIndex=mirrorIndex + 1;

end

end

end

% end of matlab function

Please kindly check attachment for its output.

Ver imagen kendrich

The function is an illustration of lists, arrays or matrices;

The elements (lists, arrays or matrices) are variables that hold multiple values

The function in Python

The function written in Python where comments are used to explain each action is as follows:

#This defines the function

def mirror(myMatrix):

   #This initializes the rows and columns to 0

   row = 0; col = 0

   #This iterates through the rows of the matrix

   for i in range(0,len(myMatrix)):

       #This iterates through the columns of the matrix

       for j in range(0,len(myMatrix[0])):

           #This flips the elements and them

           print(myMatrix[i][len(myMatrix[0])-j-1], end = " ")

           #This increments the column by 1

           col+=1

       #This resets the row and column

       row+=1; col = 0

       #This prints a new line

       print()

Read more about Python lists at:

https://brainly.com/question/16397886