Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2010-08-19
帖子: 1
声望力: 0 ![]() |
![]()
大家好,我写了一个小程序,程序中对bp,m1等做了初始赋值,然后再程序中进行运算,结果输出的时候只给出了初始值的结果。。。不知道怎么回事儿。。。
程序如下: function [up,ul,bp,bl,m1,m2,n1,n2]=findp(n,b1,b2) OBJ=xlsread('data.xlsx'); [p,q]=size(OBJ); o=OBJ(:,1)'; c=OBJ(:,2)'; ma1=tsmovavg(c,'s',n); %values started from the n-th number. up=0;ul=0;bp=0;bl=0;m1=0;m2=0;n1=0;n2=0; for i=n:q if c(i)>=o(i) && o(i)>=ma1(i) up=up+(c(i)-o(i))/o(i); m1=m1+1; elseif c(i)<o(i) && o(i)>=ma1(i) ul=ul+o(i)*b1; m2=m2+1; elseif c(i)>=o(i) && o(i)<ma(i) bl=bl+o(i)*b2; n1=n1+1; else bp=bp+(o(i)-c(i))/o(i); n2=n2+1; end end end 输出结果为up,ul,bp,bl,m1,m2,n1,n2都是0.。。。 |
![]() |
![]() |