function c = makecode(s, codeword)
global CODE;
if(length(s) == 1)
CODE{s(1)} = codeword;
else
makecode(s{1}, [codeword 1]);
display(s{1})
makecode(s{2}, [codeword 0]);
display(s{2})
end
c= CODE;
end此函数是从另一个.m文件调用的。但我没看到控制台上印着什么。我做错了吗?这就是它的名字。
sig = [1,2,3];
p = [0.6 0.3 0.1];
global CODE
s = cell(length(p),1);
s = {1,2,3};
[p, i] = sort(p);
p(2) = p(1) + p(2);
p(1) = [];
s = s(i);
s{2} = {s{1}, s{2}};
s(1) = [];
makecode(s,[])发布于 2015-06-27 15:14:29
使用celldisp显示单元格数组的内容。不要使用display。首先,将makecode的输出分配给.叫它out
out = makecode(s,[]);之后,对此使用celldisp:
>> celldisp(out)
out{1} =
0
out{2} =
1 0
out{3} =
1 1要做到自成一体,这就是我目前运行上述代码时所得到的输出。我在Windows7 R2014a专业版上使用MATLAB x64 (64位):
ans =
3
ans =
2
[3] [2]
ans =
1
ans =
[0] [1x2 double] [1x2 double]ans包含要显示的内容的最新状态.所以,如果您刚刚在ans上做了一个ans,我们就可以得到:
>> celldisp(ans)
ans{1} =
0
ans{2} =
1 0
ans{3} =
1 1https://stackoverflow.com/questions/31089429
复制相似问题