removing columns and rows from very large matrix
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
dpb
am 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...
Antworten (1)
Prasad Reddy
am 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])
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!