本文共 1687 字,大约阅读时间需要 5 分钟。
我在网上下载了几个程序,都运行不了,部分地方还看不懂,希望热心的高手门帮忙解决一下,谢谢了!
function qpskd(g,f)
%For more information, visit: www.matpic.com
%Modulation QPSK
%Example: g is a binay vector; f is the carrier frequency.
%qpskd([1 0 1 1 0 0],2)
%Author. Diego Orlando Barrag醤 Guerrero
%diegokillemall@yahoo.com
%Loja (ECUADOR)
%See also:
%http://www.mathworks.com/matlabc ... 328&objectType=FILE
if nargin > 2
error('Too many input arguments');
elseif nargin==1
f=1;
end
if f<1;
error('Frequency must be bigger than 1');
end
%*-*-*-*-*-*
l=length(g);
r=l/2;
re=ceil(r);
val=re-r;
if val~=0;
error('Please insert a vector divisible for 2');
end
%*-*-*-*-*-*
t=0:2*pi/99:2*pi;
cp=[];sp=[];
mod=[];mod1=[];bit=[];
for n=1:2:length(g);
if g(n)==0 && g(n+1)==1;
die=sqrt(2)/2*ones(1,100);
die1=-sqrt(2)/2*ones(1,100);
se=[zeros(1,50) ones(1,50)];
elseif g(n)==0 && g(n+1)==0;
die=-sqrt(2)/2*ones(1,100);
die1=-sqrt(2)/2*ones(1,100);
se=[zeros(1,50) zeros(1,50)];
elseif g(n)==1 && g(n+1)==0;
die=-sqrt(2)/2*ones(1,100);
die1=sqrt(2)/2*ones(1,100);
se=[ones(1,50) zeros(1,50)];
elseif g(n)==1 && g(n+1)==1;
die=sqrt(2)/2*ones(1,100);
die1=sqrt(2)/2*ones(1,100);
se=[ones(1,50) ones(1,50)];
end
c=cos(f*t);
s=sin(f*t);
cp=[cp die]; %Amplitude cosino
sp=[sp die1]; %Amplitude sino
mod=[mod c]; %cosino carrier (Q)
mod1=[mod1 s]; %sino carrier (I)
bit=[bit se];
end
bpsk=cp.*mod+sp.*mod1;
subplot(2,1,1);plot(bit,'LineWidth',1.5);grid on;
title('Binary Signal')
axis([0 50*length(g) -1.5 1.5]);
subplot(2,1,2);plot(bpsk,'LineWidth',1.5);grid on;
title('QPSK modulation')
axis([0 50*length(g) -1.5 1.5]);
运行时出现错误
??? Input argument "f" is undefined.
Error in ==> qpskd at 17
if f<1;
运行fsk的时候错误也一样
[本帖最后由 mooni 于 2009-4-1 17:08 编辑]
转载地址:http://seqhp.baihongyu.com/