removing columns and rows from very large matrix

3 ビュー (過去 30 日間)
Emily Heil
Emily Heil 2020 年 4 月 19 日
回答済み: Prasad Reddy 2020 年 4 月 23 日
I have a very large (4000x4000) matrix. How might I remove a full row or column from the matrix? I need to remove 58 rows and columns, so that I end up with a 3942x3942 matrix.
  1 件のコメント
dpb
dpb 2020 年 4 月 20 日
Just define which rows/columns are to be deleted...or vice versa just save the ones do want...
Simplest w/o knowing any better would be
M(1:58,:)=[]; % remove first 58 rows
M(:,1:59)=[]: % then first 58 columns
alternatively,
N=58; % put the constant in variable so can change
M=M(N+1:end,N+1:end); % save rest besides first N rows,cols
Indexing vectors can be any set of indices desired, don't have to be contiguous or at beginning/end...

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

回答 (1 件)

Prasad Reddy
Prasad Reddy 2020 年 4 月 23 日
% Generally we can choose which rows and columns to be deleated. Or we can chose which columns
% and rows to be present. create two vectors one for rows and another for columns of which you want in your answer
%you may use colen(:) operator if you have continues numbers.
%the same procedure can be chosen for deleting.
c=rand(6,6)
d=c([1,3,4,5],[3,4,5])
e=c([1,3:5],[3:5])

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by