我的M文件如下: y,?G75wij
function [G5]=fun(x); uq4sbkP
syms n1 n2 k1 k2 d; (VaN\+I:T
[subwave,nsub]=textread('subout.txt','%f %f'); J7ekIQgR
[filmwave,filmtran]=textread('filmtr.dat','%f %f'); 5u_4lNJ&
[p,q]=size(subwave); 8Wx@[!
for j=1:p; G'2=jHzMF
wavel(j)=subwave(j,1); h
^h-pd
n(j)=n1+n2/((wavel(j))^2); +;*(a3Gp
k(j)=k1*exp(k2/wavel(j)); 0BB@E(*
N(j)=n(j)-i*k(j); BZ+ mO
phase(j)=2*pi*N(j)*d/wavel(j); r!$NZ2I
ns(j)=nsub(j,1); tOg
8L2
B(j)=cos(phase(j))+ns(j)*i*sin(phase(j))/N(j); k!/_/^{
C(j)=i*N(j)*sin(phase(j))+ns(j)*cos(phase(j)); 46Q;F
T(j)=4*ns(j)/((B(j)+C(j))*conj(B(j)+C(j))); pLQSG}N
ts(j)=1-((1-ns(j))/(1+ns(j)))^2; zQ5jx5B":
t1(j)=ts(j)*T(j); z8(R.TB
tf(j)=filmtran(j,1)/100; F|Dz]ar
difference(j)=(t1(j)-tf(j))^2; tnF9Vj[#%_
end L%K_.!d^
G=symsum(difference(j),1,401); .Spi$>v
G1=subs(G,n1,sym('x(1)')); cL)rjty2
G2=subs(G1,n2,sym('x(2)')); I0H Y#z%
G3=subs(G2,k1,sym('x(3)')); X;6r$
G4=subs(G3,k2,sym('x(4)')); te*Y]-&I|/
G5=subs(G4,d,sym('x(5)')); [Ht."VxR
sIRrEea
:.S41S
H'0*CiHes
在matlab下运行 ]X:
rby$
>> options=optimset('tolfun',1e-8,'tolx',1e-8); oiv2rOFu
>> [xmin,value,flag,output]=fminsearch(@fun,[1.7,4000,0.005,400,500],options); 4 ?@uF[
S`c]Fc
?gR\A8:8
结果出错如下:
#
5f|1O
(>LHj]}K
??? Conversion to double from sym is not possible. 9{%g-u\
Error in ==> fminsearch at 175 %V %#y $l
fv(:,1) = funfcn(x,varargin{:}); r$r&4dY
bN4&\d*u#
哪位高手给看看 &Ev]x2YC