声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 819|回复: 3

[综合讨论] 请救一下,谁能帮我看看我的程序哪里出错了,怎么改

[复制链接]
发表于 2007-4-16 18:45 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
clear;
numSamplesPerSymbol = 8;
BitStreamLength = 10000;
hTransmitFilter = ones(1,numSamplesPerSymbol);
BitStream = rand(1,BitStreamLength)>0.5;
[BitStreamOne,BitStreamTwo] = SerialToParallel(BitStream);
[I_SymbolsTx,Q_SymbolsTx] = DQPSKEncoder(BitStreamOne,BitStreamTwo);
[I_WaveformTx,Q_WaveformTx] = TransmitFilter(I_SymbolsTx,Q_SymbolsTx,
hTransmitFilter,numSamplesPerSymbol);
end
function [BitStreamOne,BitStreamTwo] = SerialToParallel(BitStream)
BitStreamOne = BitStream(1:2:length(BitStream));
BitStreamTwo = BitStream(2:2:length(BitStream));

% Converts a Symbol stream to a Waveform containing impulses.
function [Waveform] = SymbolToWaveform(SymbolStream,numSamplesPerSymbol)
lenWaveform = length(SymbolStream)*numSamplesPerSymbol;
Waveform = zeros(1,lenWaveform);
Waveform(1:numSamplesPerSymbol:lenWaveform) = SymbolStream;

function [I_TxWaveform, Q_TxWaveform] = TransmitFilter(I_Symbols,Q_Symbols,hTransmitFilter,numSamplesPerSymbol)
% The first step is to convert the symbol stream into a digital signal so that it can
% be filtered.
I_Waveform = SymbolToWaveform(I_Symbols,numSamplesPerSymbol);
Q_Waveform = SymbolToWaveform(Q_Symbols,numSamplesPerSymbol);
% The next step is to filter the signal to obtain the transmit waveforms.
I_TxWaveform = conv(I_Waveform,hTransmitFilter);
Q_TxWaveform = conv(Q_Waveform,hTransmitFilter);

function Phase = CalcPhase(BitVector)
switch BitVector(1)
case 0,
switch BitVector(2)
case 0, % [0,0] case
Phase = pi/4;
case 1, % [0,1] case
Phase = 3*pi/4;
end
case 1,
switch BitVector(2)
case 0, % [1,0] case
Phase = -pi/4;
case 1, %[1,1] case
Phase = -3*pi/4;
end
end

% pi/4 shifter DQPSK Encoder.
function [I_Symbols, Q_Symbols] = DQPSKEncoder(BitStreamOneTx, BitStreamTwoTx)
% This is supposed to be (I(-1) + jQ(-1)).
InitialSymbol = (1+0i);
I_StreamLength = length(BitStreamOneTx);
Q_StreamLength = I_StreamLength;
% -------------------> Differential Modulation <------------------------------- %
% Do the Differential Modulation and generate the baseband-complex signal.
% Calculate the phase-shift due to the first symbol.
PhaseShift(1) = CalcPhase([BitStreamOneTx(1),BitStreamTwoTx(1)]);
% The first modulated symbol.
ModulatedSymbol(1) = (InitialSymbol)*exp(i*PhaseShift(1));
% The other symbols calculated iteratively.
for index = 2:1:I_StreamLength
% The phase shift due to the ith modulated symbol.
PhaseShift(index) = CalcPhase([BitStreamOneTx(index),BitStreamTwoTx(index)]);
% Rotated the modulated symbol phasor to the new position.
ModulatedSymbol(index) = ModulatedSymbol(index-1)*exp(j*PhaseShift(index));
end
% Extract the I and Q parts of the Symbol.
I_Symbols = real(ModulatedSymbol);
Q_Symbols = imag(ModulatedSymbol);
回复
分享到:

使用道具 举报

发表于 2007-4-16 19:35 | 显示全部楼层
原帖由 liyanping2007 于 2007-4-16 18:45 发表
clear;
numSamplesPerSymbol = 8;
BitStreamLength = 10000;
hTransmitFilter = ones(1,numSamplesPerSymbol);
BitStream = rand(1,BitStreamLength)>0.5;
= SerialToParallel(BitStream);
= DQPSKE ...



请给出错误信息(多看看置顶贴)
 楼主| 发表于 2007-4-16 20:50 | 显示全部楼层

回复 #2 eight 的帖子

就是没有找到调用函数
发表于 2007-4-16 20:57 | 显示全部楼层
原帖由 liyanping2007 于 2007-4-16 20:50 发表
就是没有找到调用函数


首先搞清楚哪些是子函数,哪些是主函数,否则你的问题任何人都没法看懂。搞清楚后,运行主函数,错误信息就出来了
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 22:29 , Processed in 0.052240 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表