필터 지우기
필터 지우기

Cut the last n of matrix row ?

조회 수: 3 (최근 30일)
I Made
I Made 2013년 3월 25일
e.g i have matrix a :
1
2
3
4
5
6
7
i want to cut the last 2 row of matrix A ? and become
1
2
3
4
5

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 3월 25일
편집: Andrei Bobrov 2013년 3월 25일
a = (1:7)'; n = 2;
A = a(1:end - n);
or
a(end - [n-1, 0]) = [];
  댓글 수: 1
Jan
Jan 2013년 3월 25일
편집: Jan 2013년 3월 25일
The 2nd command might be:
a(end - (n-1:0)) = [];
But this would be faster (for large problems), because the vector end-n-1:end is not created explicitly:
a(end-n-1:end) = [];

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by