⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpctest.cpp

📁 广义预测算法MATLAB转化为VC++的程序,可用于三容水箱的数据的采集.
💻 CPP
字号:
  
  
  dMm(all_); dMm(theta); dMm(P); dMm(na); dMm(nb); dMm(x); dMm(u2); dMm(u3); dMm(u4); dMm(u5); dMm(u6); dMm(y); dMm( \
    du); dMm(u); dMm(u1); dMm(Y); dMm(y1); dMm(uu); dMm(dy); dMm(rou); dMm(y2); dMm(ddu); dMm(lam); dMm(N1); dMm(Nu) \
    ; dMm(G); dMm(xs); dMm(Xs); dMm(g1); dMm(g2); dMm(g3); dMm(g4); dMm(g5); dMm(a1); dMm(b1); dMm(c1); dMm(d1); dMm( \
    a2); dMm(b2); dMm(c2); dMm(d2); dMm(a3); dMm(b3); dMm(c3); dMm(d3); dMm(a4); dMm(b4); dMm(c4); dMm(d4); dMm(a5) \
    ; dMm(b5); dMm(c5); dMm(d5); dMm(i_); dMm(i_gpctest_v0); dMm(r); dMm(a); dMm(b); dMm(e); dMm(F); dMm(g); dMm(H) \
    ; dMm(j_); dMm(j_gpctest_v1); dMm(k); dMm(k_gpctest_v2); dMm(U); 
  
  #line 1 "c:/matcom45/gpctest.m"
  call_stack_begin;
  #line 1 "c:/matcom45/gpctest.m"
_ clear((CL(all_)));
  #line 2 "c:/matcom45/gpctest.m"
_ theta = ctranspose((BR(1.0),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0));
  #line 3 "c:/matcom45/gpctest.m"
_ P = 10000.0*eye(length(theta));
  #line 3 "c:/matcom45/gpctest.m"
_ na = 2.0;
  #line 3 "c:/matcom45/gpctest.m"
_ nb = 6.0;
  #line 4 "c:/matcom45/gpctest.m"
_ x = ctranspose((BR(0.0),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0));
  #line 5 "c:/matcom45/gpctest.m"
_ u2 = 0.0;
  #line 5 "c:/matcom45/gpctest.m"
_ u3 = 0.0;
  #line 5 "c:/matcom45/gpctest.m"
_ u4 = 0.0;
  #line 5 "c:/matcom45/gpctest.m"
_ u5 = 0.0;
  #line 5 "c:/matcom45/gpctest.m"
_ u6 = 0.0;
  #line 6 "c:/matcom45/gpctest.m"
_ y = 0.0;
  #line 6 "c:/matcom45/gpctest.m"
_ du = 0.0;
  #line 6 "c:/matcom45/gpctest.m"
_ u = 0.0;
  #line 6 "c:/matcom45/gpctest.m"
_ u1 = 0.0;
  #line 6 "c:/matcom45/gpctest.m"
_ Y = y;
  #line 6 "c:/matcom45/gpctest.m"
_ y1 = 0.0;
  #line 6 "c:/matcom45/gpctest.m"
_ uu = u;
  #line 6 "c:/matcom45/gpctest.m"
_ dy = 0.0;
  #line 7 "c:/matcom45/gpctest.m"
_ rou = 0.9;
  #line 7 "c:/matcom45/gpctest.m"
_ y2 = 0.0;
  #line 7 "c:/matcom45/gpctest.m"
_ ddu = zeros(nb,1.0);
  #line 7 "c:/matcom45/gpctest.m"
_ ddu(1.0) = 10.0;
  #line 8 "c:/matcom45/gpctest.m"
_ lam = 0.1;
  #line 8 "c:/matcom45/gpctest.m"
_ N1 = 10.0;
  #line 8 "c:/matcom45/gpctest.m"
_ Nu = 1.0;
  #line 9 "c:/matcom45/gpctest.m"
_ G = zeros(N1,Nu);
  #line 9 "c:/matcom45/gpctest.m"
_ xs = (BR(0.0),semi,
  0.0);
  #line 9 "c:/matcom45/gpctest.m"
_ Xs = ctranspose(xs);
  #line 10 "c:/matcom45/gpctest.m"
_ g1 = error(TM("'ss' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  ss=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(error(TM("'tf' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  tf=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(1.0,(BR(40.0),10.0,1.0)));
  #line 10 "c:/matcom45/gpctest.m"
_ g2 = error(TM("'tf' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  tf=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(1.0,(BR(40.0),10.0,1.0),TM("Iodelay"),2.7);
  #line 10 "c:/matcom45/gpctest.m"
_ g3 = error(TM("'tf' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  tf=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(1.0,(BR(10.0),1.0),TM("Iodelay"),2.7);
  #line 11 "c:/matcom45/gpctest.m"
_ g4 = error(TM("'tf' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  tf=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(1.0,(BR(10.0),1.0));
  #line 11 "c:/matcom45/gpctest.m"
_ g5 = error(TM("'tf' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  tf=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(1.0,(BR(250.0),10.0,0.0));
  #line 12 "c:/matcom45/gpctest.m"
_ /*[a1,b1,c1,d1] = */error(TM("'ssdata' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  ssdata=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(error(TM("'c2d' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  c2d=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(g1,1.0),i_o,a1,b1,c1,d1);;
  #line 13 "c:/matcom45/gpctest.m"
_ /*[a2,b2,c2,d2] = */error(TM("'ssdata' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  ssdata=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(error(TM("'c2d' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  c2d=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(g2,1.0),i_o,a2,b2,c2,d2);;
  #line 14 "c:/matcom45/gpctest.m"
_ /*[a3,b3,c3,d3] = */error(TM("'ssdata' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  ssdata=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(error(TM("'c2d' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  c2d=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(g3,1.0),i_o,a3,b3,c3,d3);;
  #line 15 "c:/matcom45/gpctest.m"
_ /*[a4,b4,c4,d4] = */error(TM("'ssdata' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  ssdata=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(error(TM("'c2d' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  c2d=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(g4,1.0),i_o,a4,b4,c4,d4);;
  #line 16 "c:/matcom45/gpctest.m"
_ /*[a5,b5,c5,d5] = */error(TM("'ssdata' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  ssdata=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(error(TM("'c2d' was not found.\n\nIf it is a variable, make sure it is initialized before first use,\nfor example:  c2d=[];\n\nIf it is a m-file, please copy it to the current directory or add\nits directory to the matlabpath.\n") \
    )(g5,1.0),i_o,a5,b5,c5,d5);;
  #line 17 "c:/matcom45/gpctest.m"
_ i_gpctest_v0 = colon(1.0,1.0,400.0); int i_gpctest_i0;
  for (i_gpctest_i0=0;i_gpctest_i0<i_gpctest_v0.cols();i_gpctest_i0++) {
    forelem(i_,i_gpctest_v0,i_gpctest_i0);
    #line 18 "c:/matcom45/gpctest.m"
_   if (istrue(i_<30.0)||istrue((i_>=50.0&&i_<70.0))||istrue((i_>=90.0&&i_<110.0))||istrue((i_>=130.0&&i_<150.0) \
      )||istrue((i_>=170.0&&i_<190.0))||istrue((i_>=210.0&&i_<230.0))||istrue((i_>=250.0&&i_<270.0))||istrue((i_>=290.0&&i_<310.0) \
      )||istrue((i_>=330.0&&i_<350.0))||istrue((i_>=370.0&&i_<390.0))) {
      #line 21 "c:/matcom45/gpctest.m"
_     r(i_) = 20.0;
      #line 22 "c:/matcom45/gpctest.m"
    } else
    #line 22 "c:/matcom45/gpctest.m"
    if (istrue((i_>=30.0&&i_<50.0))||istrue((i_>=110.0&&i_<130.0))||istrue((i_>=190.0&&i_<210.0))||istrue((i_>=270.0&&i_<290.0) \
      )||istrue((i_>=350.0&&i_<370.0))) {
      #line 24 "c:/matcom45/gpctest.m"
_     r(i_) = 50.0;
      #line 25 "c:/matcom45/gpctest.m"
    } else {
      
      #line 26 "c:/matcom45/gpctest.m"
_     r(i_) = 0.0;
      #line 27 "c:/matcom45/gpctest.m"
    }
    #line 28 "c:/matcom45/gpctest.m"
    //r(i)=0.2;
    #line 29 "c:/matcom45/gpctest.m"
    //[theta,P]=identification(theta,P,y,x,rou,dy);
    #line 30 "c:/matcom45/gpctest.m"
    //x(2:na)=x(1:na-1);x(1)=-dy;
    #line 31 "c:/matcom45/gpctest.m"
    //x(na+2:end)=x(na+1:na+nb);x(na+1)=du;
    #line 32 "c:/matcom45/gpctest.m"
_   if (istrue(i_<=10.0)) {
      #line 33 "c:/matcom45/gpctest.m"
_     if (istrue(i_==1.0)) {
        #line 34 "c:/matcom45/gpctest.m"
_       du = 10.0;
        #line 35 "c:/matcom45/gpctest.m"
      } else {
        
        #line 36 "c:/matcom45/gpctest.m"
_       du = 0.0;
        #line 37 "c:/matcom45/gpctest.m"
      }
      #line 38 "c:/matcom45/gpctest.m"
_     u = u+du;
      
      #line 39 "c:/matcom45/gpctest.m"
    } else {
      
      #line 40 "c:/matcom45/gpctest.m"
_     a = (BR(1.0),semi,
      theta(colon(1.0,1.0,na)));
      #line 41 "c:/matcom45/gpctest.m"
_     b = theta(colon(na+1.0,1.0,theta.size()));
      #line 42 "c:/matcom45/gpctest.m"
_     /*[e,F,g,H] = */diophatine(a,b,N1,i_o,e,F,g,H);
      #line 43 "c:/matcom45/gpctest.m"
_     j_gpctest_v1 = colon(1.0,1.0,N1); int j_gpctest_i1;
      for (j_gpctest_i1=0;j_gpctest_i1<j_gpctest_v1.cols();j_gpctest_i1++) {
        forelem(j_,j_gpctest_v1,j_gpctest_i1);
        #line 44 "c:/matcom45/gpctest.m"
_       k_gpctest_v2 = colon(1.0,1.0,min(j_,Nu)); int k_gpctest_i2;
        for (k_gpctest_i2=0;k_gpctest_i2<k_gpctest_v2.cols();k_gpctest_i2++) {
          forelem(k,k_gpctest_v2,k_gpctest_i2);
          #line 45 "c:/matcom45/gpctest.m"
_         G(j_,k) = g(j_-k+1.0);
          #line 46 "c:/matcom45/gpctest.m"
        }
        #line 47 "c:/matcom45/gpctest.m"
      }
      #line 48 "c:/matcom45/gpctest.m"
_     U = inv(ctranspose(G)*G+lam*eye(Nu))*ctranspose(G);
      #line 49 "c:/matcom45/gpctest.m"
      //yy=x(1:na);ddu=x(na+1:end);
      #line 50 "c:/matcom45/gpctest.m"
_     U = U*(r(i_)-F*ctranspose((BR(y),y1,y2))-H*ddu);
      #line 50 "c:/matcom45/gpctest.m"
_     du = U(1.0);
      #line 51 "c:/matcom45/gpctest.m"
      //u1=u;
      #line 52 "c:/matcom45/gpctest.m"
_     u = u+du;
      #line 53 "c:/matcom45/gpctest.m"
_     if (istrue(u>100.0)) {
        #line 54 "c:/matcom45/gpctest.m"
_       u = 100.0;
        #line 55 "c:/matcom45/gpctest.m"
      }
      #line 56 "c:/matcom45/gpctest.m"
_     if (istrue(u<-100.0)) {
        #line 57 "c:/matcom45/gpctest.m"
_       u = -100.0;
        #line 58 "c:/matcom45/gpctest.m"
      }
      #line 59 "c:/matcom45/gpctest.m"
_     du = u-u1;
      #line 60 "c:/matcom45/gpctest.m"
    }
    #line 61 "c:/matcom45/gpctest.m"
_   uu = (BR(uu),semi,
    u);
    #line 62 "c:/matcom45/gpctest.m"
_   y2 = y1;
    #line 62 "c:/matcom45/gpctest.m"
_   y1 = y;
    #line 62 "c:/matcom45/gpctest.m"
_   ddu(colon(2.0,1.0,ddu.size())) = ddu(colon(1.0,1.0,nb-1.0));
    #line 62 "c:/matcom45/gpctest.m"
_   ddu(1.0) = du;
    
    #line 64 "c:/matcom45/gpctest.m"
_   if (istrue(i_<80.0)) {
      #line 65 "c:/matcom45/gpctest.m"
      //tau=rand;[at,bt,ct,dt]=ssdata(c2d(g1,tau));
      #line 66 "c:/matcom45/gpctest.m"
      //[nt,dt]=tfdata(ss(a1,bt,ct,dt),'v');
      #line 67 "c:/matcom45/gpctest.m"
      //xs=a1*xs+b1*u1+bt*du;
      #line 68 "c:/matcom45/gpctest.m"
      //y=c1*xs;
      #line 69 "c:/matcom45/gpctest.m"
      //Xs=[Xs;xs'];
      #line 70 "c:/matcom45/gpctest.m"
_     y = 1.757*y1-0.7788*y2+0.0115*u1+0.01058*u2+times(0.0,randn());
      #line 71 "c:/matcom45/gpctest.m"
    } else
    #line 71 "c:/matcom45/gpctest.m"
    if (istrue(i_>=80.0)&&istrue(i_<160.0)) {
      #line 72 "c:/matcom45/gpctest.m"
_     y = 1.757*y1-0.7788*y2+0.001097*u3+0.01592*u4+0.00506*u5+0.0*randn();
      #line 73 "c:/matcom45/gpctest.m"
    } else
    #line 73 "c:/matcom45/gpctest.m"
    if (istrue(i_>=160.0)&&istrue(i_<240.0)) {
      #line 74 "c:/matcom45/gpctest.m"
_     y = 0.9048*y1+0.02955*u3+0.06561*u4+0.0*randn();
      #line 75 "c:/matcom45/gpctest.m"
    } else
    #line 75 "c:/matcom45/gpctest.m"
    if (istrue(i_>=240.0)&&istrue(i_<320.0)) {
      #line 76 "c:/matcom45/gpctest.m"
_     y = 0.9048*y1+0.09515999999999999*u1+0.0*randn();
      #line 77 "c:/matcom45/gpctest.m"
    } else {
      
      #line 78 "c:/matcom45/gpctest.m"
_     y = 1.96078943915232*y1-0.96078943915232*y2+0.00197359788081*u1+0.00194745820396*u2+0.0*randn();
      #line 79 "c:/matcom45/gpctest.m"
    }
    #line 80 "c:/matcom45/gpctest.m"
_   u6 = u5;
    #line 80 "c:/matcom45/gpctest.m"
_   u5 = u4;
    #line 80 "c:/matcom45/gpctest.m"
_   u4 = u3;
    #line 80 "c:/matcom45/gpctest.m"
_   u3 = u2;
    #line 80 "c:/matcom45/gpctest.m"
_   u2 = u1;
    #line 80 "c:/matcom45/gpctest.m"
_   u1 = u;
    #line 80 "c:/matcom45/gpctest.m"
    //if (i>=200&i<280)
    #line 81 "c:/matcom45/gpctest.m"
    //   y=y+1;
    #line 82 "c:/matcom45/gpctest.m"
    //end
    #line 83 "c:/matcom45/gpctest.m"
    //[theta,P]=identification(theta,P,y,x,rou,dy);
    #line 84 "c:/matcom45/gpctest.m"
_   x(colon(2.0,1.0,na)) = x(colon(1.0,1.0,na-1.0));
    #line 84 "c:/matcom45/gpctest.m"
_   x(1.0) = -dy;
    #line 85 "c:/matcom45/gpctest.m"
_   x(colon(na+2.0,1.0,x.size())) = x(colon(na+1.0,1.0,na+nb));
    #line 85 "c:/matcom45/gpctest.m"
_   x(na+1.0) = du;
    #line 86 "c:/matcom45/gpctest.m"
    //y=0.7*y+0.9*u-0.6*u1;
    #line 87 "c:/matcom45/gpctest.m"
_   Y = (BR(Y),semi,
    y);
    #line 88 "c:/matcom45/gpctest.m"
_   dy = y-y1;
    #line 89 "c:/matcom45/gpctest.m"
_   /*[theta,P] = */identification(theta,P,y,x,rou,dy,i_o,theta,P);
    #line 90 "c:/matcom45/gpctest.m"
    //x(2:na)=x(1:na-1);x(1)=dy;
    #line 91 "c:/matcom45/gpctest.m"
    //x(na+2:end)=x(na+1:na+nb);
    #line 92 "c:/matcom45/gpctest.m"
    //x(na+1)=du;
    #line 93 "c:/matcom45/gpctest.m"
  }
  #line 94 "c:/matcom45/gpctest.m"
_ display( plot((CL(Y))) );
  #line 94 "c:/matcom45/gpctest.m"
_ display(hold());
  #line 94 "c:/matcom45/gpctest.m"
_ display( plot((CL(r))) );
  #line 94 "c:/matcom45/gpctest.m"
_ display(grid());
  call_stack_end;
  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -