フィルターのクリア

Cut the last n of matrix row ?

4 ビュー (過去 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 Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by