我在这里很困惑。 coded_msg是1和0的长字符串。码字是不同长度的码字的单元阵列(即码字(1)= 10010,码字(2)= 101等)。我想要做的是迭代到i和k的下一个索引,以及strcmp,然后如果它是true则连接到the_codeword,但是如果它是false则迭代到j。总而言之,我想要一个代码字列表,而不是一串代码字。帮助
function [coded_msg, idx] = HuffmanDecode(coded_msg, codewords)
for i = 1:length(coded_msg) % iterate through coded_msg
for j = 1:length(codewords) % iterate through codewords cell array
j_codeword = cell2mat(codewords(j)) % take the jth cell and put in matrix
for k = 1:length(j_codeword) % iterate through length of jth codeword
if strcmp(coded_msg(i), j_codeword(k)) % is true
the_codeword = [coded_msg(i)];
else % is false
end
end
end
end
end