MATLAB Answers

how to remove some row or column of a matrix at once?

9 views (last 30 days)
eri
eri on 6 Nov 2012
lets say i have a 100x100 matrix and i want to remove row 71-100 so it become 100x70 matrix

  0 Comments

Sign in to comment.

Answers (2)

Arthur
Arthur on 6 Nov 2012
Edited: Arthur on 6 Nov 2012
a = zeros(100,100); %create 100x100 matrix
a(71:100,:) = []; %remove rows 71:100

  0 Comments

Sign in to comment.


Sean de Wolski
Sean de Wolski on 6 Nov 2012
Note you say row but the new size of your matrix removed columns
Here are two ways to remove columns:
x = x(:,1:70); %glass half full
or
x(:,71:end) = []; %glass half empty

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags


Translated by