我的M文件如下: "|L"C+tE
function [G5]=fun(x); BzP,Tu{,
syms n1 n2 k1 k2 d; \A"o[A2v
[subwave,nsub]=textread('subout.txt','%f %f'); &(rWl`eTY`
[filmwave,filmtran]=textread('filmtr.dat','%f %f'); ds(?:zx#
[p,q]=size(subwave); hPDKxYD]f
for j=1:p; ^AS\a4`/
wavel(j)=subwave(j,1); jdP)y]c
n(j)=n1+n2/((wavel(j))^2); jC9us>b
k(j)=k1*exp(k2/wavel(j)); 7{L4a\JzT
N(j)=n(j)-i*k(j); G
@..?>
phase(j)=2*pi*N(j)*d/wavel(j); Ki\.w~Qs
ns(j)=nsub(j,1); t'vt'[~,U
B(j)=cos(phase(j))+ns(j)*i*sin(phase(j))/N(j); P5h|* ?=
C(j)=i*N(j)*sin(phase(j))+ns(j)*cos(phase(j)); %w*)7@,+-
T(j)=4*ns(j)/((B(j)+C(j))*conj(B(j)+C(j))); ttzNv>L,
ts(j)=1-((1-ns(j))/(1+ns(j)))^2; l%0bF9\
t1(j)=ts(j)*T(j); ff\~`n~WZ
tf(j)=filmtran(j,1)/100; t'rN7.d
difference(j)=(t1(j)-tf(j))^2; d,b4q&^X8
end ZgP%sF
G=symsum(difference(j),1,401); 4Z( #;9f
G1=subs(G,n1,sym('x(1)')); GiV%Hcx
G2=subs(G1,n2,sym('x(2)')); &X$T "Dp
G3=subs(G2,k1,sym('x(3)')); }}JMwT
G4=subs(G3,k2,sym('x(4)')); {r,Uik-nL
G5=subs(G4,d,sym('x(5)')); ;*<tU
n^t
T{k
P9
4
F4EAC|Y
z)qYW6o%
在matlab下运行 jwDlz.sW!
>> options=optimset('tolfun',1e-8,'tolx',1e-8); _FY&XL=
>> [xmin,value,flag,output]=fminsearch(@fun,[1.7,4000,0.005,400,500],options); <'a~ Y3B"o
%ou,|Dww
M&Ka^h;N
结果出错如下: !Zz;;Z
A`c%p7Z%
??? Conversion to double from sym is not possible. *@2Bh4
Error in ==> fminsearch at 175 9%/hoA)
fv(:,1) = funfcn(x,varargin{:}); 9y7N}T6
w,LtQhQ
哪位高手给看看 :Ha/^cC/3