I want to be able to select c = 2 3 5 6 8 9 12 13 15 16 18 19 22 23 25 26 28 29 32....
I need to do this all the way up to 89. Can i do this in a loop?
No products are associated with this question.
hi James, can you tell if the series follows a specific sequence or just some random values
So you want all numbers accept those ending in a 0,1 or 4? If this is correct then put an IF statement inside your FOR loop with something like: if a~= 0 && a~= 1 && a~=4, where a is the last digit of the current step being used by the for loop. Put the for loop incrementer (i = i+1) after the END of this IF statement. How you calculate, a, is up to you...
for a = 0:10:80 for b = [2,3,5,6,8,9] k = a + b; disp(k); end end
And if I'm on the way:
ind = bsxfun(@plus, 0:10:80, [2,3,5,6,8,9]'); for i = reshape(ind, 1, ) disp(i) end
Thanks. I was also just wondering if you can help me with something else similar:
for c = 11:20 if c~=11 && c~=14 && c~=17 && c~=20 break end
% how can I loop through for all values of r, which are r=11,14,17,20????
yet another way
r=9; %number of repetitions of the sequence, ex 9, max is 89 b=[2 3 5 6 8 9]; %original sequence c=repmat(b,r,1); %repeat the sequence in each row d=0:10:10*r-1; %create vector with sum values e=repmat(d,6,1)'; %create array from vector f=(c+e)'; %now all in the right place do the sum f(:)' %put the values in just a vector