MATLAB Answers

hdr mhr

Removing some elements from a vector

Asked by hdr mhr
on 1 Jun 2013
Latest activity Answered by davood fouladi
on 23 Aug 2014

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.



No products are associated with this question.

2 Answers

Answer by the cyclist
on 1 Jun 2013
Edited by the cyclist
on 1 Jun 2013
 Accepted answer

First, try to define an index that identifies the values you don't want. It sounds like this will do it:

idx = not((mod(A,100)==53));

Then, you can use that index to remove the unwanted values:

A(idx) = [];


Now that I ran the program, I realized that some of the "53" ones are missing (for some days). So the array I have is something like this: A = [53 153 253...2353 53 153...2353 153 353...2353], which a "253" is missing between 153 and 353 in that particular day. I would like to insert a specific number, say 10000 whenever there is a missing "*53", so that I can locate the missing ones. Can you think of an efficient way to do this?

Thank you

I suggest you open up a new question for this. New questions buried in comments of old questions don't get much "traffic". Be sure to give enough detail that someone can understand what you are trying to do, without reference to this one.

Sure I will do so, thanks.

Answer by davood fouladi
on 23 Aug 2014

For example,5 elements are removed from x=1:10 x(5)=[] Now what should I be removed for a number of


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!