Please compile the function file function a=test(b) to satisfy when the output matrix a is the transpose of the input matrix b. Please use a for loop instead of the built-in transpose function of matlab; Please directly use the source code of the f

1 次查看(过去 30 天)
Please compile the function file function a=test(b) to satisfy when the output matrix a is the transpose of the input matrix b. Please use a for loop instead of the built-in transpose function of matlab; Please directly use the source code of the function file created in matlab to answer
function B=MyTranspose(A)
[row, col] = size(A);
B = zeros(col, row); % Pre-allocate!
iX = 1;
for iCol = 1:col
iY = iCol;
for iRow = 1:row
B(iY) = A(iX);
iY = iY + col;
iX = iX + 1;
end
end
guys can u help me to write the command window and fix the of it ?

回答(1 个)

Walter Roberson
Walter Roberson 2020-12-2
A = [1 2 3;4 5 6]
A = 2×3
1 2 3 4 5 6
B = MyTranspose(A)
B = 3×2
1 4 2 5 3 6
Looks okay to me.
  3 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by