1. Homepage
  2. Homework
  3. UM-SJTU VG101 22SU - Homework2 - Most Repeated Numbers

UM-SJTU VG101 22SU - Homework2 - Most Repeated Numbers

Engage in a Conversation
This question has been solved

Problem 7

Write a function, named mostRepeated , that take a vector as input arguments, and output the number(s) that is/are repeated consecutively most often. For example, if you have CourseNana.COM

  CourseNana.COM

a = [1 2 2 2 1 3 2 1 4 5 1]; CourseNana.COM

mostRepeated(a) CourseNana.COM

  CourseNana.COM

The answer would be 2 , because it shows up three consecutive times. CourseNana.COM

  CourseNana.COM

Other examples: CourseNana.COM

# example 1 CourseNana.COM

Input: [1 1 1 2 2 2 3 3 3] CourseNana.COM

Output: [1 2 3] CourseNana.COM

# example 2 CourseNana.COM

Input: [0 1 1 1 0 2 2 0 1 1 1 0] CourseNana.COM

Output: [1 1] CourseNana.COM

# example 3 CourseNana.COM

Input: [1 2 3 4 5] CourseNana.COM

Output: [1 2 3 4 5] CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Matlab代写,Matlab代编,Matlab代考,Matlabhelp,Matlab作业代写,Matlab编程代写,Matlabprogramming help,Matlabassignment help,Matlabsolution,