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 ?
댓글 수: 0
답변 (1개)
Walter Roberson
2020년 12월 2일
A = [1 2 3;4 5 6]
B = MyTranspose(A)
Looks okay to me.
댓글 수: 3
Walter Roberson
2020년 12월 2일
Save that code into a file named MyTranspose.m that is on your MATLAB path (such as in your current directory)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!