removing columns and rows from very large matrix

9 views (last 30 days)
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 Comment
dpb
dpb on 20 Apr 2020
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...

Sign in to comment.

Answers (1)

Prasad Reddy
Prasad Reddy on 23 Apr 2020
% 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])

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!