transpose loop without operator

13 Ansichten (letzte 30 Tage)
matlab coder
matlab coder am 25 Jan. 2021
Kommentiert: Walter Roberson am 25 Jan. 2021
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?

Antworten (1)

KSSV
KSSV am 25 Jan. 2021
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 Kommentare
KSSV
KSSV am 25 Jan. 2021
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 am 25 Jan. 2021
Output is not correct for complex numbers.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by