MATLAB Answers

I want to get 135 as output from 11122333345555566.where 2 4 6 are noise.

1 view (last 30 days)
Geetha  K
Geetha K on 29 Apr 2020
Commented: Adam Danz on 29 Apr 2020
I want to get 135 as output from 11122333345555566.where 2 4 6 are noise.

  5 Comments

Show 2 older comments
Geetha  K
Geetha K on 29 Apr 2020
Sir, I'm counting number of fingers using simulink. But I'm continuously getting those numbers.Ibetween some noise is also adding. And I want to get only those numbers as my output

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 29 Apr 2020
Edited: Adam Danz on 29 Apr 2020
% Convert from long integer to vector of integers
K = 11122333345555566; % for demo purposes
i = 1; % for demo purposes
noise = [2 4 6];
m = floor(log10(K(i)));
v = mod(floor(K(i) ./ 10 .^ (m:-1:0)), 10);
signal = unique(v(~ismember(v,noise)), 'stable')
The lines calculating m and v are from this question.
If the number of digits in K gets too big, you'll have to use a symbolic approach that doesn't have precision limitations.

  6 Comments

Show 3 older comments
Adam Danz
Adam Danz on 29 Apr 2020
I see the column of integer values but I don't know what is noise and what is not noise.
This problem cannot be solved unless you can define what is noise and what is not noise.
Geetha  K
Geetha K on 29 Apr 2020
if the numbers repeating only one or two time. Then the number is noise. If the numbers repeating three or more times then that isn't noise.
Adam Danz
Adam Danz on 29 Apr 2020
That's much better.
% Demo values
K = 11122333345555566; % for demo purposes
i = 1; % for demo purposes
% Convert from long integer to vector of integers
m = floor(log10(K(i)));
v = mod(floor(K(i) ./ 10 .^ (m:-1:0)), 10);
% Detect when vector changes
isChg = diff([v(1)-1,v]);
% Count consecutive values
count = diff(find([isChg,true]));
% detect beginning of >2 consecutive values
isChg(isChg==1) = count;
sigStart = isChg >= 3;
% Extract unique signal values
signal = v(sigStart)
Result
signal =
1 3 5

Sign in to comment.

More Answers (0)


Translated by