フィルターのクリア

Switching first and last columns of an NxN matrix

2 ビュー (過去 30 日間)
Ray
Ray 2013 年 12 月 12 日
回答済み: Walter Roberson 2013 年 12 月 12 日
Hello,
Using matlab, I have to write a function which takes in an input matrix and flips the first and last values of the row. I CANNOT USE FLIPLR AND THIS MUST BE VECTORIZED! NO ITERATION OR SELECTION IS ALLOWED! This has to be done for either an odd or even numbered matrix. So, this needs to work for [1 2 3; 4 5 6; 7 8 9] and make it [3 2 1; 6 5 4; 9 8 7]. Similarly, it has to work for [12 13 14 15; 21 22 23 24; 31 32 33 34] and make it [15 13 14 12; 24 22 23 21; 34 32 33 31]. Any help will be appreciated! Thank you!

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 12 月 12 日
Hint: you can use "end" to refer to the last index, including doing arithmetic such as end/2

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by