当前位置: 代码迷 >> 其他开发语言 >> matlab 帮忙看上哪有有关问题,如何改,用呀
  详细解决方案

matlab 帮忙看上哪有有关问题,如何改,用呀

热度:10145   发布时间:2013-02-26 00:00:00.0
matlab 帮忙看下哪有问题,怎么改,急用呀
??? Output argument "i1" (and maybe others) not assigned during call to "E:\matlab\matlab1\work\yh.m (yh)".

Error in ==> yh at 2
S4=0;
什么意思呀???

function [h,l]=sc
p=(fix(125*rand(1,14))*5+20)%20-650之间的5的倍数
l=fliplr(sort(p));
ll=l/2;
lll=ll.*ll;
h=(105625-lll).^0.5;
while h(1)<13
    p=(fix(125*rand(1,14))*5+20)%20-650之间的5的倍数
    l=fliplr(sort(p));
    ll=l/2;
    lll=ll.*ll;
    h=(105625-lll).^0.5;
end

function [h,l]=hd
[x,l]=sc
y=[
    1,-1,0,0,0,0,0,0,0,0,0,0,0,0;
    0,1,-1,0,0,0,0,0,0,0,0,0,0,0;
    0,0,1,-1,0,0,0,0,0,0,0,0,0,0;
    0,0,0,1,-1,0,0,0,0,0,0,0,0,0;
    0,0,0,0,1,-1,0,0,0,0,0,0,0,0;
    0,0,0,0,0,1,-1,0,0,0,0,0,0,0;
    0,0,0,0,0,0,1,-1,0,0,0,0,0,0;
    0,0,0,0,0,0,0,1,-1,0,0,0,0,0;
    0,0,0,0,0,0,0,0,1,-1,0,0,0,0;
    0,0,0,0,0,0,0,0,0,1,-1,0,0,0;
    0,0,0,0,0,0,0,0,0,0,1,-1,0,0;
    0,0,0,0,0,0,0,0,0,0,0,1,-1,0;
    0,0,0,0,0,0,0,0,0,0,0,0,1,-1;
    0,0,0,0,0,0,0,0,0,0,0,0,0,1;
    ];
h=x*y;

function [i1,i2,g]=yh
S4=0;
t=0;
for i=1:12
    for ii=i+1:13
        for qq=1:1:10
            [h,l]=hd
            S1=h(1:i)*l(1:i)';
            S2=h(i+1:ii)*(l(i+1:ii)');
            S3=h(ii+1:14)*l(ii+1:14)';
            if S3-S2==0
                if S3-2*S1==0
                    t=t+1;
                    S=S1+S2+S3;
                    S1
                    S2
                    S3
                    S=S.*2.*0.97
                    i1(t,:)=[i,sum(h(1:i)),ii,sum(h(1:ii)),S];
                    if (S>S4)
                        S4=S;
                        i2=[i,sum(h(1:i)),ii,sum(h(1:ii)),S4];
                    end
                end
  相关解决方案