In an array of numbers (0 to 255 of data type uint8), if any number occurs more than 3 times, I would like to insert number '255' (uint8) in between the array and return the position where '255' was inserted. Can somebody please help me?
Show older comments
Example:
input = [1 255 0 0 0 9 9 9 1 6 6 6 6 6 6 1]; % array of numbers (uint8)
output = [1 255 0 0 0 255 9 9 9 255 1 6 6 6 255 6 6 6 255 1];
% output must have 255 inserted at positions 6, 10, 15, 19 because 0, 9, 6, 6 have occurred three times respectively
outputIndex = [6 10 15 19]; % outputIndex must indicate the positions where 255 was inserted
2 Comments
MKN
on 11 Feb 2015
Image Analyst
on 11 Feb 2015
Seems like a quirky thing to want to do. Like a sort of manual watershed segmentation. Why do you want to do that? Also, don't use input as the name of a variable since it's already the name of a built-in function.
Accepted Answer
More Answers (0)
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!