-3

I have a MATLAB matrix that is 100,000x2 (100,000 rows, two columns)

How do I remove all the rows after row number 47,526?

In other words, I want to truncate the 100,000x2 matrix into a 47526x2 matrix

user4757174
  • 416
  • 2
  • 4
  • 14
  • 3
    You can assign a new matrix to the rows you want using the `:` operator – Aidin Jan 22 '17 at 19:54
  • 3
    Have you read https://www.mathworks.com/help/matlab/getting-started-with-matlab.html, particularly https://www.mathworks.com/help/matlab/learn_matlab/array-indexing.html? – beaker Jan 22 '17 at 20:04
  • 2
    Possible duplicate of [Delete Specific Rows in Matlab](http://stackoverflow.com/questions/17227141/delete-specific-rows-in-matlab) – hbaderts Jan 30 '17 at 05:53

2 Answers2

2

Assuming your matrix is named A:

A = A(1:47526, :);
rayryeng
  • 102,964
  • 22
  • 184
  • 193
Aidin
  • 1,230
  • 2
  • 11
  • 16
1
YourMatrix(47527:end,:) = [] ;
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
Ofek Shilon
  • 14,734
  • 5
  • 67
  • 101