creating a new matrix without certain rows with elements below a certain value
14 views (last 30 days)
I want to create a new matrix which is has the same values as my original matrix, M, minus those rows whose first column values are less than 3.
Does anyone know how I could correct my code to do this?
Tommy on 8 Jun 2020
If I'm understanding correctly, I believe your third line is enough (with the addition of a colon in the second subscript of M to avoid linear indexing):
idx = M(:,1) >= 3; % indices of rows to keep
N = M(idx,:);