Multiples of 5

23 views (last 30 days)
Hi, ive got an array of numbers and i want to delete the array values whose index is a multiple of 5. How can i do this?

Accepted Answer

Walter Roberson
Walter Roberson on 26 May 2012
for K = numel(YourArray): -1 : 1
if (K / 5) == fix(K / 5)
YourArray(K) = [];
end
end
There are definitely easier ways, but your question sounds like an assignment.
  1 Comment
Image Analyst
Image Analyst on 26 May 2012
Other ways would be the use the rem() or mod() function.

Sign in to comment.

More Answers (1)

Andrei Bobrov
Andrei Bobrov on 26 May 2012
x - your array
out = x(rem(x,5) ~= 0)
  2 Comments
Edward
Edward on 30 May 2012
It wasn't but thanks anyway!

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by