If I have to perform arithmetic encoding on a sequence such as "222101" where one of the digits is 0 , how do I solve the error "The symbol sequence parameter must be a vector of positive finite integers"?

3 次查看(过去 30 天)
I am using the function arithenco(seq, counts) and no error is observed if the sequence is made "222131". But I need the message to be specifically "222101". What change in code required to get rid of the error?

采纳的回答

Walter Roberson
Walter Roberson 2020-7-2
In R2020a, you need to edit line 173 of arithenco to change
if ~all(seq > 0) || ~all(isfinite(seq)) || ~isequal(seq, round(seq)) || ...
to be >= 0 instead of > 0
and you need to change line 67
symbol = seq(k);
to
symbol = seq(k) + 1;
I might have missed some changes.
I would suggest to you that it would be far more robust to simply add 1 to all elements of your sequence,
[2 2 2 1 0 1] + 1

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by