-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
  • 396
  • 2
  • 3
  • 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
  • 100,316
  • 21
  • 181
  • 185
Aidin
  • 972
  • 2
  • 9
  • 16
1
YourMatrix(47527:end,:) = [] ;
Luis Mendo
  • 109,078
  • 12
  • 70
  • 142
Ofek Shilon
  • 13,332
  • 5
  • 59
  • 95