这是我照着书上程序写的一个费诺编码器的程序,但当我输入矩阵时总是对这行程序[p,x]=array(p,x)报错,显示函数或变量“array”无法识别,大伙能我帮我看一下是什么原因吗?(下面程序第一个if语句后面有end,我给删掉了,不删掉发出来后面的程序会被系统添加上横线给挡住)
function [w,L,q]=fano(p)
%Fano编码生成器
%p为信源概率矢量
%w为编码返回的码字
%L为平均编码长度
%q为编码效率
if length(find(p<=0))~=0
error('Not a prob.vitor,negative component(s)')
if abs(sum(p)-1)>10e-10
error('Not a prob.vector,components do not add up to 1')
end
n=length(p);
x=1:n;
[p,x]=array(p,x);
L=ceil(-log2(p));
for i=1:n
current_index =i;
j=1;
current_p=p;
while(1)
[next_p,code_num,next_index]=compare(current_p,current_index);
current_index=next_index;
current_p=next_p;
w(i,j)=code_num;
j=j+1;
if(length(current_p)==1)
break;
end
end
l(i)=length(find(abs(w(i,:))~=0));
end
L=sum(p.*l);
H=sum(-p.*log2(p));
q=H/L;
end
你借鉴的书的名字他用的版本是什么版本
疑似同学了 希望你早点搞出来 让我也嫖一下