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

Important note: please, make sure to write the code by accurately following the

ID: 671855 • Letter: I

Question

Important note: please, make sure to write the code by accurately following the intructions given in the question. Make sure to write down the function and the script file. I've asked for help in MATLAB questions before, and people answered it with different methods than the one specifically mentioned in the question. Also, tell me which code belongs to the function file and which code belongs to thescriptfile,so writing comments to explain the code would be highly appreciated. I posted this question TWICE previously, but the code either didn't work, or didn't follow the intructions in the question so I would also really appreciate it if you could test the code before giving me the answer and also make sure that it follows the instructions. Thank you so much

this is the question:

MATLAB Programming exercise (20 points) Develop a function in Matlab to generate the transpose of a matrix. Prepare a script to generate a matrix transpose (by your function) of matrices A and B. Do not use Matlab matrix operation A' to achieve the results (you can use it to test your function) A=112 81 B 6 -1

Explanation / Answer

function tm = transposeMatrix(A)

    [rows columns] = size(A);
% In transpose vector , the rows and columns are reversed
    T = zeros(columns,rows);
    for i = 1 : rows
        for j=1: columns
% This is the core logic. Here row elements are stored as column elements
% For example element in row pos (1,2) , will be element in row pos (2,1), that's why reversing the indexes indicated by i and j to j and i in tranpose matrix
        T(j,i) = A(i,j);
        end
    end
    tm = T;
end

A = [ 6 -1; 12 8; -5 4];
Tcustom = transposeMatrix(A);

disp("AT: By Custom function");
disp(Tcustom);

disp("AT: By library function");
disp(transpose(A));

B = [4 0; 0.5 2];

BTcustom = transposeMatrix(B);

disp("BT: By Custom function");
disp(BTcustom);
disp("BT: By library function");
disp(transpose(B));


////////////////////////////sample output//////////////////////////////////////////////