我的M文件如下: o- QG&
]
function [G5]=fun(x); lPcVhj6No%
syms n1 n2 k1 k2 d; Re,$<9V
[subwave,nsub]=textread('subout.txt','%f %f'); ZR-s{2sl
[filmwave,filmtran]=textread('filmtr.dat','%f %f'); +V+*7s%fL
[p,q]=size(subwave); ZDkD%SCy
for j=1:p; CNRU"I+jU
wavel(j)=subwave(j,1); "kBqY+:Cn
n(j)=n1+n2/((wavel(j))^2); EfBVu
k(j)=k1*exp(k2/wavel(j)); :Nj`_2
N(j)=n(j)-i*k(j); l88a#zUQDN
phase(j)=2*pi*N(j)*d/wavel(j); qzlMn)e
ns(j)=nsub(j,1); :CkR4J!m3
B(j)=cos(phase(j))+ns(j)*i*sin(phase(j))/N(j); a[74%L?
C(j)=i*N(j)*sin(phase(j))+ns(j)*cos(phase(j)); #C,f/PXfaB
T(j)=4*ns(j)/((B(j)+C(j))*conj(B(j)+C(j))); jPYe_y
ts(j)=1-((1-ns(j))/(1+ns(j)))^2; q4.dLU,1
t1(j)=ts(j)*T(j); m~j\?mb{+
tf(j)=filmtran(j,1)/100; FH`'1iVH
difference(j)=(t1(j)-tf(j))^2; Q(;B)
end |N=@E,33
G=symsum(difference(j),1,401); r0g/ :lJi
G1=subs(G,n1,sym('x(1)')); bDFCZH-:'O
G2=subs(G1,n2,sym('x(2)')); 4j/ iG\
G3=subs(G2,k1,sym('x(3)')); ,JQxs7@2k
G4=subs(G3,k2,sym('x(4)')); 'Elj"Iiu
G5=subs(G4,d,sym('x(5)')); h\u0{!@}
,y8I)+
dp[w?AMhM9
Zu0;/_rN
在matlab下运行 mj(&`HRs4
>> options=optimset('tolfun',1e-8,'tolx',1e-8); lR@i`)'?U
>> [xmin,value,flag,output]=fminsearch(@fun,[1.7,4000,0.005,400,500],options); ^0s\/qyqm
4$?wD <
# +QWi0B
结果出错如下: -#S)}NEn
i#]aV]IT
??? Conversion to double from sym is not possible. pe!dm}!h[
Error in ==> fminsearch at 175 7dlKdKH
fv(:,1) = funfcn(x,varargin{:}); b,rH&+2H
`z?KL(rI
哪位高手给看看 /[20e1 w!