我的M文件如下: H|F>BjXn5
function [G5]=fun(x); g_>)Q
syms n1 n2 k1 k2 d; Ca+d
?IS
[subwave,nsub]=textread('subout.txt','%f %f'); 6$SsdT|8B
[filmwave,filmtran]=textread('filmtr.dat','%f %f'); z2!NBOv
[p,q]=size(subwave); .XLe\y
for j=1:p; }'kk}2ej`
wavel(j)=subwave(j,1); Zi7(lG
n(j)=n1+n2/((wavel(j))^2); Fxv~;o#
k(j)=k1*exp(k2/wavel(j)); k6[t$|lMy
N(j)=n(j)-i*k(j); :+]6SC0ql
phase(j)=2*pi*N(j)*d/wavel(j); rVQ:7\=Z
ns(j)=nsub(j,1); { +
[rJ_
B(j)=cos(phase(j))+ns(j)*i*sin(phase(j))/N(j); `{F8#
C(j)=i*N(j)*sin(phase(j))+ns(j)*cos(phase(j)); Gpe h#Q4x
T(j)=4*ns(j)/((B(j)+C(j))*conj(B(j)+C(j))); X@x:
F|/P
ts(j)=1-((1-ns(j))/(1+ns(j)))^2; AP3SOT3I
t1(j)=ts(j)*T(j); 3m7$$N|
tf(j)=filmtran(j,1)/100; }}t"^m s
difference(j)=(t1(j)-tf(j))^2;
.j7|;Ag
end 3h0w8(k;
G=symsum(difference(j),1,401); A!iH g__/t
G1=subs(G,n1,sym('x(1)')); _3A$zA
G2=subs(G1,n2,sym('x(2)')); s.zH.q,
G3=subs(G2,k1,sym('x(3)')); s}|IRDpp
G4=subs(G3,k2,sym('x(4)')); J>hl&J
G5=subs(G4,d,sym('x(5)')); aM? 7'8/
7jts;H=
n{4&('NRFP
e;rs!I!Yw
在matlab下运行 BAoqO
Xv
>> options=optimset('tolfun',1e-8,'tolx',1e-8); 2Y 6/,W
>> [xmin,value,flag,output]=fminsearch(@fun,[1.7,4000,0.005,400,500],options); ,vg8iRa
cY\-e?`=4
( Y/
DMQ
结果出错如下: /8W}o/,s5
~Gwn||g78
??? Conversion to double from sym is not possible. j nI)n*
Error in ==> fminsearch at 175 1+#Vj#
fv(:,1) = funfcn(x,varargin{:}); 4Iy\
'ARQ7 Q[`
哪位高手给看看 3: mF!