transpose loop without operator

14 次查看(过去 30 天)
I would like to write a MATLAB function called ''myTranspose()'' which gets a matrix and returns the transpose of this matrix using loops, BUT without using transpose operator ('). can someone help me?

回答(1 个)

KSSV
KSSV 2021-1-25
A = rand(3) ;
[m,n] = size(A) ;
B = A ;
for i = 1:m
for j = 1:n
B(i,j) = A(j,i) ;
end
end
  3 个评论
KSSV
KSSV 2021-1-25
Yes..you are right.....I generally don't do it....but I did this time...vexed up with OPs asking simple questions and not giving a try.
Walter Roberson
Walter Roberson 2021-1-25
Output is not correct for complex numbers.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by