deleting rows from matrix and saving as a new matrix

1 回表示 (過去 30 日間)
Elina Park
Elina Park 2018 年 11 月 28 日
回答済み: Star Strider 2018 年 11 月 28 日
Hello,
If I have a matrix 20 x 20, and I want to delete row 2 and 7,
I would use something like
MTX_1([2,7],:) = []
is there a way to save this new matrix as a separate array (such as MTX_2), while preserving the original MTX_1?
Thank you.

回答 (1 件)

Star Strider
Star Strider 2018 年 11 月 28 日
Probably the easiest way:
MTX_2 = MTX_1(setdiff(1:size(MTX_1,1),[2,7]),:)
This creates ‘MTX_2’ while leaving ‘MTX_1 unchanged.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by