transpose loop without operator

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 日

1 投票

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 件のコメント

Birdman
Birdman 2021 年 1 月 25 日
Instead of directly giving the answer, you should have encouraged the user to solve the problem by guiding accordingly.
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.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2021 年 1 月 25 日

コメント済み:

2021 年 1 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by