我的M文件如下: ]~CGzV
function [G5]=fun(x); Ix !O&_6s
syms n1 n2 k1 k2 d; |#$Wh+,*
[subwave,nsub]=textread('subout.txt','%f %f'); ( du<0J|PT
[filmwave,filmtran]=textread('filmtr.dat','%f %f'); 'x
lK_Z
[p,q]=size(subwave); 1Ah
for j=1:p; >F6'^9|
wavel(j)=subwave(j,1); FSd842O
n(j)=n1+n2/((wavel(j))^2); Dms6"x2
k(j)=k1*exp(k2/wavel(j)); B|gyr4]
N(j)=n(j)-i*k(j); Gr&5 mniu
phase(j)=2*pi*N(j)*d/wavel(j); |i7|QLUT
ns(j)=nsub(j,1); XKLkJZN
B(j)=cos(phase(j))+ns(j)*i*sin(phase(j))/N(j); JadXd K=gE
C(j)=i*N(j)*sin(phase(j))+ns(j)*cos(phase(j)); rgdDkWLXC
T(j)=4*ns(j)/((B(j)+C(j))*conj(B(j)+C(j))); 2 Q,e1'=
ts(j)=1-((1-ns(j))/(1+ns(j)))^2; T?:Vw laE
t1(j)=ts(j)*T(j); aGx`ec*t
tf(j)=filmtran(j,1)/100; V9NE kS
difference(j)=(t1(j)-tf(j))^2; 2ksX6M3kY
end ]$!-%pNv
G=symsum(difference(j),1,401); Xa#`VDh
G1=subs(G,n1,sym('x(1)')); *xA&t)z(i
G2=subs(G1,n2,sym('x(2)')); #g\O*oYaw
G3=subs(G2,k1,sym('x(3)')); 3|-)]^1O
G4=subs(G3,k2,sym('x(4)')); Eic/#j{4
G5=subs(G4,d,sym('x(5)')); f"q='B9_T\
DzYi>
E:*
SaMg)s~B
]re1$W#*
在matlab下运行 'J#u;KJ
>> options=optimset('tolfun',1e-8,'tolx',1e-8); :w:hqe|_
>> [xmin,value,flag,output]=fminsearch(@fun,[1.7,4000,0.005,400,500],options); )8p FPr
rePJ4i [y
v4=9T<[
结果出错如下: sL75C|f9
\-$wY%7
??? Conversion to double from sym is not possible. ,1EyT>
Error in ==> fminsearch at 175 \"{+J
fv(:,1) = funfcn(x,varargin{:}); 9^QiFgJy
_@;t^j+l
哪位高手给看看 n.n;'p9t@