我是靠谱客的博主 天真柜子,最近开发中收集的这篇文章主要介绍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);

求大神帮帮忙

最后

以上就是天真柜子为你收集整理的matlab主函数和子函数的区别,MATLAB 主程序和子程序之间的问题 子程序出错的全部内容,希望文章能够帮你解决matlab主函数和子函数的区别,MATLAB 主程序和子程序之间的问题 子程序出错所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部