series of consecutive numbers in a matrix
5 views (last 30 days)
Show older comments
hi everyone,
i need to make a vec who has the num of the rows of the series of consecutive numbers.
how can i write a program to find where those consecutive numbers are? i've tried using a for loop but haven't really got anywhere
for eg
if this is my matrix :
numMat= [2 3 5; 6 1 3; 4 5 6; 3 3 3; 9 8 7; 1 2 3];
the vec will be :
indVec= [3,6]
my scrips is:
numMat= [2 3 5; 6 1 3; 4 5 6; 3 3 3; 9 8 7; 1 2 3];
indVec=[];
count=1;
for i= 1: size(numMat,1)
for j= 1: size (numMat,2)
if numMat(i,j)== numMat(i,j+1)
indVec (count)= i;
count= count+1;
end
end
end
2 Comments
Stephen23
on 10 Dec 2018
@noa goldman: it is not appreciated when you delete your question like that. Now the answers have no context and are meaningless to anyone else. You unilaterally decided that our volunteers efforts should only be useful to you, which is very unfair for us.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!