How can I clear columns and rows of a matrix?

1 回表示 (過去 30 日間)
Ayob
Ayob 2014 年 1 月 19 日
編集済み: Ayob 2014 年 1 月 19 日
I have matrix like A which is in a square form p*p and a line matrix B in a form of q*1 (q<p).
I want to clear rows and columns of matrix A with the help of B. for example:
A=[1 2 3 4;5 6 7 8;9 10 11 12;1 2 3 4]
and
B=[2 4]
I should eliminate second row and column 'As B(1)=2' and fourth row and column 'As B(2)=4'.
So A becomes [1 3;9 11].

採用された回答

Amit
Amit 2014 年 1 月 19 日
編集済み: Amit 2014 年 1 月 19 日
A(B,:) = [];
A(:,B) = [];
  2 件のコメント
Ayob
Ayob 2014 年 1 月 19 日
編集済み: Ayob 2014 年 1 月 19 日
I check it,but didn't work .
??? Subscripted assignment dimension mismatch.
Amit
Amit 2014 年 1 月 19 日
I edited it and tested it. It works.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by