切换到宽版
  • 广告投放
  • 稿件投递
  • 繁體中文
    • 3633阅读
    • 1回复

    [求助]fminsearch应用出错 [复制链接]

    上一主题 下一主题
    离线fanyushan
     
    发帖
    36
    光币
    52
    光券
    0
    只看楼主 倒序阅读 楼主  发表于: 2010-07-19
    我的M文件如下: f.)z_RyGd  
    function [G5]=fun(x); <$z6:4uN_  
    syms n1 n2 k1 k2 d; yM}~]aQ y  
    [subwave,nsub]=textread('subout.txt','%f %f'); R5Pk>-KF  
    [filmwave,filmtran]=textread('filmtr.dat','%f %f'); ty ESDp%  
    [p,q]=size(subwave); {&dbxj-'  
    for j=1:p; = -bGH   
        wavel(j)=subwave(j,1); $|"Y|3&X  
        n(j)=n1+n2/((wavel(j))^2); d?ru8  
        k(j)=k1*exp(k2/wavel(j)); ml,FBBGq|-  
        N(j)=n(j)-i*k(j); $Z|HFV{  
        phase(j)=2*pi*N(j)*d/wavel(j); /aTW X  
        ns(j)=nsub(j,1); JkShtLEr  
        B(j)=cos(phase(j))+ns(j)*i*sin(phase(j))/N(j); Nwwn #+  
        C(j)=i*N(j)*sin(phase(j))+ns(j)*cos(phase(j)); MpK3+4UMa  
        T(j)=4*ns(j)/((B(j)+C(j))*conj(B(j)+C(j))); ~ECIL7,  
        ts(j)=1-((1-ns(j))/(1+ns(j)))^2; 8NnGN(a*D  
        t1(j)=ts(j)*T(j); O:E0htdWr  
        tf(j)=filmtran(j,1)/100; {'8td^JEE  
        difference(j)=(t1(j)-tf(j))^2; |E?PQ?P  
    end XQ3"+M_KG  
    G=symsum(difference(j),1,401); t]IHQ8  
    G1=subs(G,n1,sym('x(1)')); Y5{KtW  
    G2=subs(G1,n2,sym('x(2)')); vmzc0J+3p  
    G3=subs(G2,k1,sym('x(3)')); %<)!]8}P*  
    G4=subs(G3,k2,sym('x(4)')); m>{a<N  
    G5=subs(G4,d,sym('x(5)')); VQ"Z3L3-4  
    gU&y5s~  
    lfw|Q@  
    ty8>(N(~  
    在matlab下运行 yJK:4af;.  
    >> options=optimset('tolfun',1e-8,'tolx',1e-8); T095]*Hm  
    >> [xmin,value,flag,output]=fminsearch(@fun,[1.7,4000,0.005,400,500],options); gc\/A\F<  
    ,&~-Sq) ~  
    f\;w(_  
    结果出错如下: Wsb>3J  
    =,b6yV+$D  
    ??? Conversion to double from sym is not possible. 1oc@]0n  
    Error in ==> fminsearch at 175 4Ei8G]O $_  
    fv(:,1) = funfcn(x,varargin{:}); 8NkyT_\  
    u`CHM:<<?  
    哪位高手给看看 !,+<?o y  
     
    分享到
    离线fanyushan
    发帖
    36
    光币
    52
    光券
    0
    只看该作者 1楼 发表于: 2010-07-21
    哪位高人告诉我,错误在哪里呀。M文件复制到命令行,执行,一切正常,就是在求解多元函数0值时,不知道哪里错了。 M"Af_Pbx  
    ?W_8 X2(`  
    >V?W_oM)  
    万分感谢呀