Make a program that adds consecutive numbers range from zero
Make a program that adds consecutive numbers range from zero to a specific number in Matlab. Please post code. Thanks
Solution
I am giving the code to find the consecutive numbers for the given set of numbers.
Try this code to get the consecutive numbers
a(diff(a)==1)
Gives the first value
or
p=find(diff(a)==1)
q=[p;p+1];
a(q) % this gives all the pairs of consecutive numbers
