how can i creat an sub array with last n number of column of an array?
조회 수: 32 (최근 30일)
이전 댓글 표시
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).
댓글 수: 0
채택된 답변
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
댓글 수: 0
추가 답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!