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일

1 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

질문:

2013년 3월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by