Reputation: 1
I need to eliminate alternate rows of an array, like i have an array of 23847X1 and i need the odd rows and finally making it into 11924X1. It is in .mat file and i want the resultant in the .mat file as well.
Upvotes: 0
Views: 1417
Reputation: 420951
Try yourMatrix(1:2:size(yourMatrix, 2))
.
The 1:2:N
selects all elements from 1
to N
with step 2
.
A more complete example:
> M=[1, 2, 3, 4, 5, 6, 7]
M =
1 2 3 4 5 6 7
> OddM = M(1:2:size(M, 2))
OddM =
1 3 5 7
To load / store data in data.mat
, follow H.Muster's advice below:
load('data.mat'); x = x(1:2:end,:); save('data.mat', 'x')
Upvotes: 3