声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 788|回复: 1

[编程技巧] 请教高手:帮我看这个程序

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

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

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

x
这个程序是关于pi/4-dqpsk的调制
主程序如下:
BitStreamLength = 10000;
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);

每次运行的错误显示如下:
??? Error: File: F:\资料\matlab仿真\pi4DQPSK\zhuchengxu.m Line: 6 Column: 71
Missing variable or function.

以下是各部分的调用函数:
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);


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);
回复
分享到:

使用道具 举报

发表于 2007-5-7 09:37 | 显示全部楼层
原帖由 liyanping2007 于 2007-5-7 09:18 发表
这个程序是关于pi/4-dqpsk的调制
主程序如下:
BitStreamLength = 10000;
BitStream = rand(1,BitStreamLength)>0.5;
= SerialToParallel(BitStream);
= DQPSKEncoder(BitStreamOne,BitStreamTwo);
= T ...



文件路径问题,建议不要使用中文。更多的请参阅“置顶贴:聚宝盆”里面的以下信息:


8. 对于初学者,建议先阅读以下链接的精华帖[原创]写给学习 matlab 的新手们

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-11-19 08:38 , Processed in 0.062082 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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