H_A
H_A

Reputation: 677

Removing some unwanted elements from the vector

I have a vector that consists of some numbers in the following way:

A = [153 244 253 353 453 530 653 ...]

The pattern is that there is always 153,253,353,...,2353 (these represent time i.e. 1:53am,...11:53pm) for a day. In between these *53 numbers there are some numbers that I don't wish to keep them. For example between 353 and 453, a 433 appears which needs to be removed from the vector. So the final result I wish to get is vector

A = [153 253 353 ...2353]

(of course in the original vector I have, this pattern for one day is repeated for a whole year).

Any thought on how to do this?

I would really appreciate any answer.

Upvotes: 2

Views: 170

Answers (2)

Rasman
Rasman

Reputation: 5359

An alternative (and possibly faster) answer to Oleg is to use the modulus operator:

A((mod(A,100))==53)

Upvotes: 3

Oleg
Oleg

Reputation: 10676

Keep only the 53'' of each hour:

idx = ismember(A,53:100:2353);
A(idx)

Upvotes: 2

Related Questions