I have a fairly large 2x2 matrix containing date and temperatures. There is a cluster of NaNs and incorrect data. I used find
to get the index that contains the incorrect data. These indexes are stored in another variable. How do i remove the rows (date and value) corresponding to the indices?
Thanks.
Asked
Active
Viewed 5,613 times
1

Ricky Bhola
- 55
- 1
- 2
- 5
-
2An example would make this clearer - please include a sample of the code you've already written. Also, how is your matrix large if it's only 2x2? – Simon MᶜKenzie Jun 21 '13 at 03:31
1 Answers
5
fairly large 2x2 matrix
makes little or no sense.
This is part from MATLAB documentation
You can delete rows and columns from a matrix by assigning the empty array [] to those rows or columns. Start with
A = magic(4)
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
Then, delete the second column of A using
A(:, 2) = []
This changes matrix A to
A =
16 3 13
5 10 8
9 6 12
4 15 1
Also you can delete multiple rows/columns at once:
A([1 3],:)=[]
A =
5 10 8
4 15 1

anandr
- 1,622
- 1
- 12
- 10