我的M文件如下: R/iXO~/"J
function [G5]=fun(x); 1^vN?#Kt
syms n1 n2 k1 k2 d; ~qRP.bV%f
[subwave,nsub]=textread('subout.txt','%f %f'); &<4Jyhm:o
[filmwave,filmtran]=textread('filmtr.dat','%f %f'); 0^4Tem@
[p,q]=size(subwave); r@ ]{`qA
for j=1:p; r'"H8>UZ%
wavel(j)=subwave(j,1); lbMb
n(j)=n1+n2/((wavel(j))^2); a
*>$6H;
k(j)=k1*exp(k2/wavel(j)); hl8[A-d(R
N(j)=n(j)-i*k(j); `uY77co6
phase(j)=2*pi*N(j)*d/wavel(j); w18kTa!4@
ns(j)=nsub(j,1); HI55):Eb
B(j)=cos(phase(j))+ns(j)*i*sin(phase(j))/N(j); Z{|wjZb(
C(j)=i*N(j)*sin(phase(j))+ns(j)*cos(phase(j)); )jvYJ9s
T(j)=4*ns(j)/((B(j)+C(j))*conj(B(j)+C(j))); 2!}5shB
ts(j)=1-((1-ns(j))/(1+ns(j)))^2; N|wI=To
t1(j)=ts(j)*T(j); C/!kMMh>vV
tf(j)=filmtran(j,1)/100; M,zUg_ @
difference(j)=(t1(j)-tf(j))^2; b8(94t|;U
end oJEind>8O
G=symsum(difference(j),1,401); BTqY_9
G1=subs(G,n1,sym('x(1)')); ;V@o 2a
G2=subs(G1,n2,sym('x(2)')); ><+wH b
G3=subs(G2,k1,sym('x(3)')); J'W6NitMr
G4=subs(G3,k2,sym('x(4)')); YFeF(k!!n
G5=subs(G4,d,sym('x(5)')); w\!aKeP'
!IF#L0z
,iV|^]X3$/
r1f##
在matlab下运行 NvY%sx,
>> options=optimset('tolfun',1e-8,'tolx',1e-8); qq
G24**9v
>> [xmin,value,flag,output]=fminsearch(@fun,[1.7,4000,0.005,400,500],options); p{gJVP#l'Z
63 F@Ft
#fd;]
结果出错如下: [5yLg
f!AcBfaLr
??? Conversion to double from sym is not possible. {94qsVxQZ
Error in ==> fminsearch at 175 }Ndknut,
fv(:,1) = funfcn(x,varargin{:}); {HHc}8
F[5[@y
哪位高手给看看 _NA[g:DZ&O