Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Below is the code to rotate by 90 but how to rotate a matrix by 180 and 270 without using matlab fuctions

1 回表示 (過去 30 日間)
vetri veeran
vetri veeran 2014 年 10 月 13 日
閉鎖済み: Matt J 2014 年 10 月 13 日
% Below is the code to rotate by 90 but how to rotate a matrix by 180 and 270
A=[1 2 3 4;5 6 7 8;10 11 12 13]
[nr,nc] = size(A);
At = zeros(nc,nr);
for i = 1:nr
for j = 1:nc
At(j,i) = A(i,j); end end
disp(At)
  1 件のコメント
Matt J
Matt J 2014 年 10 月 13 日
No, the code you've posted will transpose A, not rotate it by 90 degrees. Compare
>> At, rot90(A)
At =
1 5 10
2 6 11
3 7 12
4 8 13
ans =
4 8 13
3 7 12
2 6 11
1 5 10
Since the code you've posted is also code that I gave you in another thread as a homework hint, I will now close this thread.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by