code with out using loops
古いコメントを表示
how can I write a code segment that flips an N*M array up to down *Do not use loops or flip function
2 件のコメント
James Tursa
2020 年 12 月 26 日
What have you done so far? What specific problems are you having with your code?
Stephen23
2020 年 12 月 27 日
Backup of original thread with question by omar khasawneh on 25th December 2020:
採用された回答
その他の回答 (1 件)
omar khasawneh
2020 年 12 月 26 日
0 投票
1 件のコメント
Image Analyst
2020 年 12 月 26 日
OK, that works as long as you have written a special rot180() function. I'm not seeing it in base MATLAB. If I instead use imrotate() to do that part:
A = [1 2 3 ; 4 5 6; 7 8 9];
A = A' % transpos
% A = rot180(A2) %rotation
A = imrotate(A, 180)
I get
A =
1 4 7
2 5 8
3 6 9
A =
9 6 3
8 5 2
7 4 1
Which is not flipped up to down. It also flips left to right.
The solution most MATLABers would use is a single line of code using the hint I gave. So here is a little bit more:
A = A(startingValue : stepValue : endingValue, :);
That's it. One single line of code. See if you can supply the values.
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!