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

1 次查看(过去 30 天)
I want to get 135 as output from 11122333345555566.where 2 4 6 are noise.
  5 个评论

请先登录,再进行评论。

采纳的回答

Adam Danz
Adam Danz 2020-4-29
编辑:Adam Danz 2020-4-29
% 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 个评论
Geetha  K
Geetha K 2020-4-29
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 2020-4-29
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by