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

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

    上一主题 下一主题
    离线fanyushan
     
    发帖
    36
    光币
    52
    光券
    0
    只看楼主 倒序阅读 楼主  发表于: 2010-07-19
    我的M文件如下: ;$4&Qp:#  
    function [G5]=fun(x); o Qo5y_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-a Xx  
    [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  
     
    分享到
    离线fanyushan
    发帖
    36
    光币
    52
    光券
    0
    只看该作者 1楼 发表于: 2010-07-21
    哪位高人告诉我,错误在哪里呀。M文件复制到命令行,执行,一切正常,就是在求解多元函数0值时,不知道哪里错了。 .5}Gt>4XM  
    |g!d[ct]  
    Z*UVbyC  
    万分感谢呀