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?

Respuestas (1)

KSSV
KSSV el 25 de En. de 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 comentarios

Birdman
Birdman el 25 de En. de 2021
Instead of directly giving the answer, you should have encouraged the user to solve the problem by guiding accordingly.
KSSV
KSSV el 25 de En. de 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 el 25 de En. de 2021
Output is not correct for complex numbers.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 25 de En. de 2021

Comentada:

el 25 de En. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by