
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The matlab code for a function named 'dsc' that identifies and returns consecutive repeating numbers in a given input vector. The function uses a for loop and conditional statements to compare each element in the vector with the previous one, and if they are the same, the loop continues to search for the next repeating number. The function returns an output vector 'b' containing the consecutive repeating numbers.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

a=[1 2 2 2 3 1] %input dsc (a) % calling function function z=dsc(a) %function definition c=2; b(1)=a(1); for(x=2:1:length(a)) if (a(x)==a(x-1)) x=x+1; else b(c)=a(x); x=x; c=c+1; end end b %output