Info
This question is closed. Reopen it to edit or answer.
could anyone help me to solve the issue
1 view (last 30 days)
Show older comments
If there are 12 numbers in a row how to select 1,3,5,7,9,11 numbers.
2 Comments
Answers (3)
Tiasa Ghosh
on 15 Aug 2018
One can check whether the index number is odd or even with
if mod(i,2)==1
% do something
end
3 Comments
Tiasa Ghosh
on 15 Aug 2018
oh yes, I am sorry I deleted that comment. It was:
a=1:12;
a(1),a(3),a(5)...
wouldn't this require more manual work?
Image Analyst
on 15 Aug 2018
If you are going to select 1 number, or 3 numbers, or 5 numbers, or however many numbers you want, you can specify their indexes but you need to decide which one(s). For example, if you are going to select (extract) 3 numbers, which three are they? The first three? The last three? The numbers at indexes 4, 6, and 10? You need some kind of rule.
Or do you want every possible combination of 3 numbers?
For example, let's say you wanted the 3 numbers at indexes 2, 8, and 11, from vector v, you'd do
v3 = v([2,8,11])
1 Comment
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!