removing columns and rows from very large matrix

9 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by