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1,1,1,0,0,0,1,1,0,0;
1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0];
tx = [];
values = randsrc(1,1,[0:15]);
for k=1:length(values)
sym = values(k);
tx = [tx chip_values((sym+1),1:end)];
end;
tx = tx.';
h = modem.oqpskmod;
y = modulate(h, tx);
g = modem.oqpskdemod(h);
z = demodulate(g, y);
length(z)
for k=1:length(tx)
if(tx(k)~=z(k))
fprintf('%d %d\n',tx(k),z(k));
end;
end;
我的问题是在这个简单的情况下,为什么我的 tx 和 z 不包含相同的值,即使我还没有引入任何噪声?谢谢!
tx 的值如下所示:
第 1 列至第 13
0 1 1 0 0 0 0 0 0 1 1 1 0
列 第 14 至 26
1 1 1 1 0 1 1 1 0 0 0 1 1
列 第 27 至 32
0 0 1 0 0 1
列 z 的值如下所示:
第 1 至 13
3 0 1 1 0 0 0 0 0 0 1 1 1
列 第 14 至 26
0 1 1 1 1 0 1 1 1 0 0 0 1
列 第 27 至 32 列
1 0 0 1 0 0
h =
Type: 'OQPSK Modulator'
M: 4
PhaseOffset: 0
Constellation: [1x4 double]
SymbolOrder: 'Binary'
SymbolMapping: [0 1 2 3]
InputType: 'Integer'
g =
Type: 'OQPSK Demodulator'
M: 4
PhaseOffset: 0
Constellation: [1x4 double]
SymbolOrder: 'Binary'
SymbolMapping: [0 1 2 3]
OutputType: 'Integer'
DecisionType: 'Hard decision'
i am trying to simulate the IEEE 802.15.4/ZigBEE PHY,...
chip_values = [
1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0;
1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0;
0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0;
0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1;
0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1;
0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0;
1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1;
1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1;
1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1;
1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1;
0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1;
0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0;
0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0;
0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1;
1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0;
1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0];
tx = [];
values = randsrc(1,1,[0:15]);
for k=1:length(values)
sym = values(k);
tx = [tx chip_values((sym+1),1:end)];
end;
tx = tx.';
h = modem.oqpskmod;
y = modulate(h, tx);
g = modem.oqpskdemod(h);
z = demodulate(g, y);
length(z)
for k=1:length(tx)
if(tx(k)~=z(k))
fprintf('%d %d\n',tx(k),z(k));
end;
end;
my question is in this simple case why my tx and z do not contain the same values eventhough i did not introduce any noise yet? thanks!
values of tx comes as follows:
Columns 1 through 13
0 1 1 0 0 0 0 0 0 1 1 1 0
Columns 14 through 26
1 1 1 1 0 1 1 1 0 0 0 1 1
Columns 27 through 32
0 0 1 0 0 1
values of the z comes as follows:
Columns 1 through 13
3 0 1 1 0 0 0 0 0 0 1 1 1
Columns 14 through 26
0 1 1 1 1 0 1 1 1 0 0 0 1
Columns 27 through 32
1 0 0 1 0 0
h =
Type: 'OQPSK Modulator'
M: 4
PhaseOffset: 0
Constellation: [1x4 double]
SymbolOrder: 'Binary'
SymbolMapping: [0 1 2 3]
InputType: 'Integer'
g =
Type: 'OQPSK Demodulator'
M: 4
PhaseOffset: 0
Constellation: [1x4 double]
SymbolOrder: 'Binary'
SymbolMapping: [0 1 2 3]
OutputType: 'Integer'
DecisionType: 'Hard decision'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很难说,因为我没有安装通信工具箱,但我建议使用文档中示例中给出的更简单的输入来尝试。 使用
例如 。然后查看输出而不仅仅是比较。差异是否等于或接近机器精度?您不会告诉我们打印出什么(它们是否匹配?)。尝试计算 tx 和 z 之间的差异。它接近 eps (对我来说是 2.2204e-016)吗?
输入的数据和输出的数据之间是否存在转换?告诉我们数据发生了什么。
更新
我很高兴您发布了实际的输入和输出。看起来 z 向右移动了一位(并且由于某种原因在开头有一个 3),这意味着你丢失了最后一位。查看 Matlab 文档,有一个注释说
我认为这可以解释问题。基本上,只需在调制器的输入末尾填充一个额外的 0,从解调器的输出中取出第一个元素,然后就可以开始工作了。
It's hard for me to tell since I don't have the communications toolbox installed, but I would suggest trying this with a simpler input as given in the examples in the documentation. Use
for instance. Then look at the output rather than just comparing. Are the differences at or near machine precision? You don't tell us what is printed out (are they matching or not?). Try taking the difference between tx and z. Is it near eps (2.2204e-016 for me)?
Is there a shifting between the data going in and the data coming out? Tell us what is going on with the data.
Update
I'm glad that you posted that actual input and output. It looks like z is shifted one to the right (and has a 3 at the beginning for some reason) which means you lose the last bit. Looking at the Matlab documentation, there is a note that says
I think that explains the problem. Basically, just pad an extra 0 at the end of the input to the modulator, take off the first element from the output of the demodulator, and you're in business.