我的M文件如下: ;$4&Qp:#
function [G5]=fun(x); oQo5y_o~
syms n1 n2 k1 k2 d; 3r,Kt&2$
[subwave,nsub]=textread('subout.txt','%f %f'); A
McZm0c`
[filmwave,filmtran]=textread('filmtr.dat','%f %f'); ?FR-aXx
[p,q]=size(subwave); H(M{hfa|
for j=1:p; j}(m$j'
wavel(j)=subwave(j,1); AA=eWg
n(j)=n1+n2/((wavel(j))^2); $ye>;Ek
k(j)=k1*exp(k2/wavel(j)); 88?O4)c
N(j)=n(j)-i*k(j); WNKP';(a@G
phase(j)=2*pi*N(j)*d/wavel(j); P6'Se'f8
ns(j)=nsub(j,1); ;mwnAO
B(j)=cos(phase(j))+ns(j)*i*sin(phase(j))/N(j); ga S}>?qk
C(j)=i*N(j)*sin(phase(j))+ns(j)*cos(phase(j)); \.Op6ECV9
T(j)=4*ns(j)/((B(j)+C(j))*conj(B(j)+C(j))); L$kB(Brw
ts(j)=1-((1-ns(j))/(1+ns(j)))^2; [/n@BK
t1(j)=ts(j)*T(j); }owl7G3
tf(j)=filmtran(j,1)/100; YB2gxZ
difference(j)=(t1(j)-tf(j))^2; S QGYH
end =1,1}OucP
G=symsum(difference(j),1,401); B_b5&M@
G1=subs(G,n1,sym('x(1)')); %*Uc,V
G2=subs(G1,n2,sym('x(2)')); Y}<%~z#.4
G3=subs(G2,k1,sym('x(3)')); S3E5^n\\
G4=subs(G3,k2,sym('x(4)')); #V#!@@c;?
G5=subs(G4,d,sym('x(5)')); 've[Mx
#reW)P>
ijzwct#.
C4|OsC7J
在matlab下运行 wp>
z04
>> options=optimset('tolfun',1e-8,'tolx',1e-8); YgS,5::SU
>> [xmin,value,flag,output]=fminsearch(@fun,[1.7,4000,0.005,400,500],options); e+{lf*"3
*yjnC
{s*2d P)
结果出错如下: g]`YI5
#h4FLF_w
??? Conversion to double from sym is not possible. P~iZae
Error in ==> fminsearch at 175 p?4[nS-,
fv(:,1) = funfcn(x,varargin{:}); ZrZDyXL
eR6vO5to
哪位高手给看看 (+/d*4