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 Exchange에서 Loops 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