Find a value in a vector
Show older comments
Hello, I need some help.
I want to search in this vector s=[25 33 56 25 98 25 33 25 33 25 68 25 98], for this value, Pattern=25, and I want to memorize in a variable what numbers are repeated after this Pattern I choose and the one that is repeated most of the time to keep it in a variable FinalPrediction.
Pattern=25 => What is up next after Pattern :numbers.repeated= 33,98,33,33,68,98 => Results that number 33 is repeating 3 times after Pattern=25 That means my next number after the last number from s vector is number 33 .
>>FinalPrediction=33
>> s.final = [25 33 56 25 98 25 33 25 33 25 68 25 98, 33 ]
I don't now how to write a cod that gives to me this result
Thank you!
Accepted Answer
More Answers (1)
Sulaymon Eshkabilov
on 6 Jun 2021
V = [ .......] %
Most_V = mode(V);
VFinal = [V, mode(V)];
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!