フィルターのクリア

how can i creat an sub array with last n number of column of an array?

22 ビュー (過去 30 日間)
jakaria babar
jakaria babar 2018 年 12 月 21 日
コメント済み: jakaria babar 2018 年 12 月 22 日
s =
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
a =
3 4 5
8 9 10
13 14 15
i am not getting 'a' using the code
A=s(1:n;end-n-1:end).

採用された回答

madhan ravi
madhan ravi 2018 年 12 月 21 日
編集済み: madhan ravi 2018 年 12 月 21 日
By indexing you can achieve it :
s= [1 2 3 4 5
6 7 8 9 10
11 12 13 14 15];
n = 3 ; % last n number of columns
a = s(:,n:end)
Gives:
a =
3 4 5
8 9 10
13 14 15

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2018 年 12 月 21 日
s(end-n+1:end,end-n+1:end)

jakaria babar
jakaria babar 2018 年 12 月 21 日
I want to built a function of creating a n by n subarray of bottom right of an array of any dimension.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by