matlab中 主程序和子程序,MATLAB 主程序和子程序之间的问题 子程序出错

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

子程序如下:

function [Xd,Ad,Bd,A,B,g0,h0]=initial_h0(n,k,Wa,SRLa,SXLa)

% This function generates the initial guess for the numerator polynomial

% h(p).

%--------------------Inputs:

%Wa: Normalized angular frequency which includes

%sample points for the load reflectance over the

%pass band.

%SRLa: Row vector. Real part of the load reflectance

%SXLa: Row vector. Imaginary part of the load reflectance

%---------------------Output:

%h0=[...] row vector. Initial for the

%polynomial_h(p).

N=length(Wa);

g0=initial_g0(n,k,Wa,SRLa,SXLa);

for j=1:N

W=Wa(j);

p=(sqrt(-1)*W);

% Step 1: Generate row vector Xd for linear regression of the Auxiliary polynomial.

Xd(j)=W*W;

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

% Step 2: Generate gR and gX from g0(p)

SRL=SRLa(j);

SXL=SXLa(j);

gval=polyval(g0,p);

gR=real(gval);

gX=imag(gval);

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

%

% Step 3: Generate array vectors Ad and Bd to generate polynomilas A(x) and B(x)

% Note that A9x)=hR and B(x)=hX/w

Ad(j)=gR*SRL+gX*SXL;

Bd(j)=-(gX*SRL-gR*SXL)/W;

end

%

% Step 4: Find the polynomials A(x) and B(x) by polynomial curve fitting:

ng=length(g0);

n=ng-1;

[A,B]=polyfitAB(n,Xd,Ad,Bd);

%

% Step 5: Determine the initial coefficients h0=[...]

h0=ABtoh(n,A,B);

return

主程序如下:

% PROGRAM FOR CHAPTER 11: Initialization for Example 6

clear

%--------------------------------inputs:---------------------------------------

n=4;

k=0;

ntr=1;

T0=0.84

%----------Measured antenna data normalized with respect to f0=100MHz, and R0=50ohm.

Wa=[0.3000 0.3300 0.3600 0.3900 0.4200 0.4500 0.4800 0.5100 0.5400 0.5700 0.6000]

SRLa =[0.6233 0.3869 0.1504 0.1168 0.2850 0.4775 0.6208 0.7172 0.7818 0.8259 0.8567]

SXLa =[-0.5541 -0.5401 -0.3407 -0.0096 0.2157 0.2838 0.2715 0.2316 0.1854 0.1399 0.0971]

%---------------Generation of Initials----------------

[Xd,Ad,Bd,A,B,g0,h0]=initial_h0(n,k,Wa,SRLa,SXLa);

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

%

na=n+1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%

% Start Optimization using simplest version of the LSQNONLIN

%

% Type design prefernce:

%ntr=1: design with transformer

%ntr=0: design without transformer.

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

%

OPTIONS=OPTIMSET('MaxFunEvals',20000,'MaxIter',50000);

%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Design with transformer:

if ntr==1,

x0=h0;

% Call optimization function lsqnonlin:

x=lsqnonlin('sopt11',x0,[],[],OPTIONS,T0,ntr,k,Wa,SRLa,SXLa);

%

h=x;

end

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

% Design without transformer:

if ntr==0,

for r=1:na-1

x0(r)=h0(r);

end

%Call optimization function lsqnonlin:

x=lsqnonlin('sopt11',x0,[],[],OPTIONS,T0,ntr,k,Wa,SRLa,SXLa);

for r=1:na-1

h(r)=x(r);

end

h(na)=0;

end

% Generate strictly hurwits polynomial g(p) from optimized h(p):

g=Hurwitzpoly_g(h,k);

% Compute the optimized transducer power gain

nopt=length(Wa);

for j=1:nopt

w=Wa(j);

SR=SRLa(j);

SX=SXLa(j);

L11=complex(SR,SX);

%COMPUTATION OF GAIN

g=Hurwitzpoly_g(h,k);

T=gain(w,h,g,k,L11);

Ta(j)=T;

end

na=n+1

for i=1:na

y(i)=g(na-i+1);

x(i)=h(na-i+1);

end

%

if k==0

% Syntisize the lossless equalizer from its back-end reflection

% coefficient:clc

[m CV]=synthesis(x,y);

end

plot(Wa,Ta)

CV=general_synthesis(h,g);

运行错误结果为:

??? Undefined command/function 'polyfitAB'.

Error in ==> initial_h0 at 38

[A,B]=polyfitAB(n,Xd,Ad,Bd);

Error in ==> UntitledEX6 at 13

[Xd,Ad,Bd,A,B,g0,h0]=initial_h0(n,k,Wa,SRLa,SXLa);

求大神帮帮忙

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值