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.
采纳的回答
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')
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 个评论
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 Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!