我的M文件如下: &n
wg$z{Y
function [G5]=fun(x); zq&lxySa
syms n1 n2 k1 k2 d; pj6Cvq4bD
[subwave,nsub]=textread('subout.txt','%f %f'); Qa+gtGtJ
[filmwave,filmtran]=textread('filmtr.dat','%f %f'); =%`"
[p,q]=size(subwave); on$a]zx'@
for j=1:p; 7\lb+^$
wavel(j)=subwave(j,1); C~*m&,@TT^
n(j)=n1+n2/((wavel(j))^2); .}wir,
k(j)=k1*exp(k2/wavel(j)); Yn/-m
Z
N(j)=n(j)-i*k(j); n66_#X
phase(j)=2*pi*N(j)*d/wavel(j); DQ$/0bq
ns(j)=nsub(j,1); !T)>q%@ai
B(j)=cos(phase(j))+ns(j)*i*sin(phase(j))/N(j); 5**xU+&
C(j)=i*N(j)*sin(phase(j))+ns(j)*cos(phase(j)); ~r3g~MCHS
T(j)=4*ns(j)/((B(j)+C(j))*conj(B(j)+C(j))); We2=|AB
ts(j)=1-((1-ns(j))/(1+ns(j)))^2; I6_+3}Hm{
t1(j)=ts(j)*T(j); lVHJ}(<'p
tf(j)=filmtran(j,1)/100; w.\:I[
difference(j)=(t1(j)-tf(j))^2; ej `$-hBBV
end -u{:39y{n
G=symsum(difference(j),1,401); ikC;N5Sw
G1=subs(G,n1,sym('x(1)')); !RI&FcK
G2=subs(G1,n2,sym('x(2)')); $}@ll^
G3=subs(G2,k1,sym('x(3)')); c-F&4V
G4=subs(G3,k2,sym('x(4)')); %k_JLddlW
G5=subs(G4,d,sym('x(5)')); ]Az >W*Y
t$J-6dW
K""04Ew*pV
2#!D" F
在matlab下运行 0ro+FJ r
>> options=optimset('tolfun',1e-8,'tolx',1e-8); B4C`3@a
>> [xmin,value,flag,output]=fminsearch(@fun,[1.7,4000,0.005,400,500],options); 42M3c&@P
;_!;D#:
'Tn$lh
结果出错如下: Y]PZ| G)
}PVB+i M
??? Conversion to double from sym is not possible. 6*E7}
Error in ==> fminsearch at 175 n"JrjvS
fv(:,1) = funfcn(x,varargin{:}); VQyDd~Za
J{Jxb1:c
哪位高手给看看 WG,{:|!E