liyanping2007 发表于 2007-4-16 18:45

请救一下,谁能帮我看看我的程序哪里出错了,怎么改

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

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

function = 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, % case
Phase = pi/4;
case 1, % case
Phase = 3*pi/4;
end
case 1,
switch BitVector(2)
case 0, % case
Phase = -pi/4;
case 1, % case
Phase = -3*pi/4;
end
end

% pi/4 shifter DQPSK Encoder.
function = 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();
% 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();
% 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);

eight 发表于 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 ...


请给出错误信息(多看看置顶贴)

liyanping2007 发表于 2007-4-16 20:50

回复 #2 eight 的帖子

就是没有找到调用函数

eight 发表于 2007-4-16 20:57

原帖由 liyanping2007 于 2007-4-16 20:50 发表
就是没有找到调用函数

首先搞清楚哪些是子函数,哪些是主函数,否则你的问题任何人都没法看懂。搞清楚后,运行主函数,错误信息就出来了
页: [1]
查看完整版本: 请救一下,谁能帮我看看我的程序哪里出错了,怎么改