matlab运行错误类型,matlab运行出现数据类型错误,在别人电脑上运行无此问题

GIG3版本是matlab 7.11.0

Undefined function or method 'CP0201_BITS' for input arguments of type 'double'.

Error in ==> CP0402_TRANSMITTER_2PAM_TH at 57

bits = CP0201_BITS(numbits);

附代码如下:

function [bits,THcode,Stx,ref]=CP0402_TRANSMITTER_2PAM_TH

% ----------------------------

% Step Zero - Input Parameters

% ----------------------------

Pow = -30;      % Average transmitted power (dBm)

fc = 50e9;      % sampling frequency

numbits = 5;    % number of bits generated by the source

Ts = 10e-9;     % frame time, i.e. average pulse repetition

%  period [s]

Ns = 5;         % number of pulses per bit

Tc = 1e-9;      % chip time [s]

Nh = 10;        % cardinality of the Time Hopping code

Np = 5;         % period of the Time Hopping code

Tm = 0.5e-9;    % pulse duration [s]

tau = 0.25e-9;  % shaping factor for the pulse [s]

G = 1;

% G=0 -> no graphical output

% G=1 -> graphical output

% ----------------------------------------

% Step One - Simulating Transmission Chain

% ----------------------------------------

% binary source

bits = CP0201_BITS(numbits);

% repetition coder

repbits = cp0201_repcode(bits,Ns);

% time hopping code

[THcode]=cp0201_TH(Nh,Np);

% PAM + TH

[PAMTHseq,THseq] = cp0402_2PAM_TH(repbits,fc,Tc,Ts,THcode);

% Shaping filter

power = (10^(Pow/10))/1000;      % average transmitted

%  power (watts)

Ex = power * Ts;                 % energy per pulse

w0 = cp0201_waveform(fc,Tm,tau); % energy normalized pulse

%  waveform

wtx = w0 .* sqrt(Ex);            % pulse waveform

Sa = conv(PAMTHseq,wtx);         % output of the filter

%  (with modulation)

Sb = conv(THseq,wtx);            % output of the filter

%  (without modulation)

% Output generation

L = (floor(Ts*fc))*Ns*numbits;

Stx = Sa(1:L);

ref = Sb(1:L);

% ---------------------------

% Step Two - Graphical Output

% ---------------------------

if G

F = figure(1);

set(F,'Position',[32 223 951 420]);

tmax = numbits*Ns*Ts;

time = linspace(0,tmax,length(Stx));

P = plot(time,Stx);

set(P,'LineWidth',[2]);

ylow=-1.5*max(wtx);

yhigh=1.5*max(wtx);axis([0 tmax ylow yhigh]);

AX=gca;

set(AX,'FontSize',12);

X=xlabel('Time [s]');

set(X,'FontSize',14);

Y=ylabel('Amplitude [V]');

set(Y,'FontSize',14);

for j = 1 : numbits

tj = (j-1)*Ns*Ts;

L1=line([tj tj],[ylow yhigh]);

set(L1,'Color',[0 0 0],'LineStyle','--',...

'LineWidth', [2]);

for k = 0 : Ns-1

if k > 0

tn = tj + k*Nh*Tc;

L2=line([tn tn],[ylow yhigh]);

set(L2,'Color',[0.5 0.5 0.5],...

'LineStyle','-.', 'LineWidth', [2]);

end

for q = 1 : Nh-1

th = tj + k*Nh*Tc + q*Tc;

L3=line([th th],[0.8*ylow 0.8*yhigh]);

set(L3,'Color',[0 0 0], 'LineStyle',...

':', 'LineWidth', [1]);

end

end

end

end % end of graphical output

其中出现问题的函数定义如下:function [bits]=CP0201_BITS(numbits)

bits=rand(1,numbits)>0.5;

为什么在调用的时候出现上述错误呢?求解答

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值