亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? dd2mc.c

?? 卡爾曼濾波
?? C
字號(hào):
/***********************************************************************
 * MEX TEMPLATE FOR DD2M-FILTER
 * ----------------------------
 * Make a copy of this file, give it a new name and do the following:
 * o Write a function (in C) that contains the state equation.
 * o In the same file write a function containing the (multiple)
 *   observation equations.
 * o Specify the name of the file in the "define variable" KALMFILE.
 *   Remember to use " " around the name.
 * o Assign XFUNC to the name of the state equation function and assign
 *   YFUNC to the name of the observation equation function (no " "!).
 * o Compile with the appropriate Matlab command:
 *   >> mex my_dd2m.c kalmlblx.o    % PC-Linux gcc compiler
 *   >> mex my_dd2m.c kalmlblcc.obj % Matlab lcc compiler
 *
 ***********************************************************************/
#define KALMFILE "demosysm.c"
#define XFUNC demotu
#define YFUNC demoobs
/***********************************************************************/

/*
 *     INCLUDE HEADERS
 */
#include <stdio.h>
#include <math.h>
#include <time.h>
#include "mex.h"


/*
 *     DEFINES ASSOCIATED WITH MATRIX MANIPULATION 
 */
#define ON 1
#define OFF 0
#define RUNCHK ON             /* Run-time checks switched on/off. */

/* "Inline" functions.                                                 */
/* ( No run-time checks is performed, when inline functions are used ) */
#define nof_rows(ptm)                      (ptm->row)                           /* See getrows */
#define nof_cols(ptm)                      (ptm->col)                           /* See getcols */
#define vec_len(ptv)                       (ptv->row+ptv->col-1)                /* See length  */
#define get_val(ptm,row_pos,col_pos)       (ptm->mat[row_pos][col_pos])         /* See mget    */
#define put_val(ptm,row_pos,col_pos,value) ((ptm->mat[row_pos][col_pos])=value) /* See mput    */
#define rvget(ptv,element)                 (ptv->mat[0][element])               /* See vget    */
#define cvget(ptv,element)                 (ptv->mat[element][0])               /* See vget    */
#define rvput(ptv,element,value)           ((ptv->mat[0][element])=value)       /* See vput    */
#define cvput(ptv,element,value)           ((ptv->mat[element][0])=value)       /* See vput    */


/* Declaration of the "abstract" data-type. */

typedef struct {          /* Matrix structure for C library  */
	int row;               /* These are meant to be "private" */
	int col;               /* and should only be accessed via */
	double **mat;          /* the "member functions" below.   */
} matrix;


typedef struct {               /* Matrix structure for C library  */
	int row;               /* These are meant to be "private" */
	int col;               /* and should only be accessed via */
	int **mat;             /* the "member functions" below.   */
} intmatrix;

typedef struct {          /* Optional initializations        */
	matrix *init;          /* Initialization parameters       */
	int Aflag;             /* Linear state update (deterministic term)    */
	int Fflag;             /* Linear state update (stochastic term)       */
	int Cflag;             /* Linear output equation (deterministic term) */
	int Gflag;             /* Linear output equation (stochastic term)    */
	matrix *A;             /* State transition matrix         */
	matrix *C;             /* Output sensitivity matrix       */
	matrix *F;             /* Process noise coupling matrix   */
	matrix *G;             /* Observ. noise coupling matrix   */
} optpar;


typedef struct {          /* Observation data structure       */
   int    ny;             /* Dimension of observation vector  */
	int    nobs;           /* Number of observations in stream */
	int    nw;             /* Dimension of obs. noise vector   */
	matrix *y;             /* Mean of process noise            */
   intmatrix *tidx;       /* Time stamps for obs. in .y       */
	matrix *wmean;         /* Mean of measurement noise        */
	matrix *Sw;            /* Root of noise covariance matrix  */
	matrix *y0;            /* Storage of current outp. estimate*/
   matrix *y02;           /* Storage of 2 * output estimate   */
	matrix *ybar;          /* Storage of scaled output estimate*/
	matrix *Sy;            /* Root of outp. covariance matrix  */
	matrix *Sy0;           /* Rectangular root of outp. cov mat*/
	matrix *Sytmp;         /* Storage of intermediate results  */
	matrix *Syx;           /* Root of cross-covariance matrix  */
	matrix *Syw;           /* Root of cross-covariance matrix  */
	matrix *Syx2;          /* Root of cross-covariance matrix  */
	matrix *Syw2;          /* Root of cross-covariance matrix  */
	matrix *K;             /* Kalman gain                      */
	matrix *Sxlong;        /* Long root of covariance matrix   */
	matrix *hSwt;          /* Sw multiplied by h and transposed*/
	int    yidx;           /* Index to next observation        */
	int    lasttime;       /* Sample no. for last observation  */
	matrix *wtmp;          /* temp vector                      */
	matrix *wtmp2;         /* temp vector                      */
	matrix *syp;           /* temp vector                      */
	matrix *sym;           /* temp vector                      */
	int Cflag;             /* Linear output equation (deterministic term) */
	int Gflag;             /* Linear output equation (stochastic term)    */
	matrix *C;             /* Output sensitivity matrix        */
	matrix *G;             /* Observ. noise sensitivity matrix */
	int syx2_start;        /* Start index of Syx2 in Sy        */
	int syw2_start;        /* Start index of Syw2 in Sy        */
	double scal3;          /* Constant used in dd2mfilt        */
} obsstruct;


/* Declaration of the "member functions".   */
matrix *mmake( int, int );
void mfree( matrix* );
void mprint( matrix* );
void merror( char* );
int getrows( matrix* );
int getcols( matrix* );
void minit( matrix* );
void madd( matrix*, matrix*, matrix* );
void mset( matrix*, matrix*);
intmatrix *intmmake( int, int );
void intmfree( intmatrix* );


/*
 *     PROTOTYPE DECLARATION
 */
matrix* mat2sm(const mxArray*);
void sm2mat(mxArray*, matrix*);
intmatrix* mat2intsm(const mxArray*);
void intsm2mat(mxArray*, intmatrix*);
int dd2filtm(int (*xfct)(matrix*, matrix*, matrix*, matrix*, int),
            int (*yfct)(matrix*, matrix*, matrix*, int),
	    matrix*, matrix*, matrix*, matrix*, matrix*, matrix*, 
            obsstruct*, int, optpar*);

#include KALMFILE

/*********************************************************************************
 *                                                                               *
 *    dd2mc gateway routine                                                      *
 *    ---------------------                                                      *
 *                                                                               *
 *    This is a C-version of the Matlab function 'dd2m'.                         *
 *    Type 'help dd2m' from Matlab for information on                            *
 *    how to call the function.                                                  *
 *                                                                               *
 *                                                                               *
 *    Written by Magnus Norgaard                                                 *
 *    LastEditDate: Nov. 11, 2001                                                *
 *                                                                               *
 *********************************************************************************/


/*********************************************************************************
 *                                                                               *
 *                           G A T E W A Y   R O U T I N E                       *
 *                                                                               *
 *********************************************************************************/
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  /*
   >>>>>>>>>>>>>>>>>>           VARIABLE DECLARATIONS          <<<<<<<<<<<<<<<<<<<
   */
   matrix *xhat_data, *Smat, *xbar, *Sxbar, *Sv, *u;
   optpar *opt;
   int a, samples=0, nx, ny=0, *ptmi, streams, i;
   mxArray  *Matmatrix, *M;
   obsstruct *obs;


  /*
   >>>>>>>>>>>>>>>>      CHECK FOR PROPER NUMBER OF ARGUMENTS      <<<<<<<<<<<<<<<
   */
   if (nrhs<7 || nrhs>8)
      mexErrMsgTxt("Wrong number of input arguments");
   else if (nlhs > 2)
       mexErrMsgTxt("Too many output arguments");
 
  /*
   >>>>>>>>>>>>>>>>>     CONVERT INPUT ARGUMENTS TO SM FORMAT     <<<<<<<<<<<<<<<<
   */
  /* Convert Sxbar */
  a = 1;

  nx = mxGetN(prhs[a]);
  if (nx==0 || nx!=mxGetM(prhs[a]))
     mexErrMsgTxt("Dimension mismatch in P0");
  else
     Sxbar = mat2sm(prhs[a]);
     
  /* Convert xbar and initialize if necessary */
  a = 0;
  if (mxGetN(prhs[a])==0 || mxGetM(prhs[a])==0){
     xbar = mmake(nx,1);
     minit(xbar);
  }
  else
     xbar = mat2sm(prhs[a]);
    
  /* Convert Sv */
  a = 2;
  if (mxGetN(prhs[a])!=mxGetM(prhs[a]))
     mexErrMsgTxt("Dimension mismatch in Q");
  else
     Sv = mat2sm(prhs[a]);


  /* Convert y */
  a  = 5;
  if(!mxIsCell(prhs[a]))
     mexErrMsgTxt("Argument 'y' must be a cell array");
  if(mxGetM(prhs[a])!=1 || mxGetM(prhs[a])>mxGetN(prhs[a]))
     mexErrMsgTxt("Argument 'y' must be a 'row' vector of cells");
  streams = mxGetN(prhs[a]);          /* Observation streams */

  /* Allocate memory for array of 'obs' structures */
  obs = (obsstruct*) malloc(streams*sizeof(obsstruct));
  
  /* Extract each 'y' matrix from cell array */
  for(i=0;i<streams;i++){
     M = mxGetCell(prhs[a],i);
     obs[i].ny = mxGetN(M);
     obs[i].nobs = mxGetM(M);
     if (obs[i].ny==0 || obs[i].nobs==0)
     mexErrMsgTxt("Observation matrix is empty");
     obs[i].y = mat2sm(M);
     ny += obs[i].ny;
  }


  /* Convert timeidx */
  a = 6;
  if(!mxIsCell(prhs[a]))
     mexErrMsgTxt("Argument 'timeidx' must be a cell array");
  if(mxGetM(prhs[a])!=1 || mxGetN(prhs[a])!=streams)
     mexErrMsgTxt("'timeidx' must have the same dimension as 'y'");

  /* Extract each 'timeidx' matrix from cell array */
  for(i=0;i<streams;i++){
     M = mxGetCell(prhs[a],i);
     if (mxGetN(M)==0 || mxGetM(M)==0)
        mexErrMsgTxt("No time stamps - 'timeidx' is empty");
     if (mxGetM(M)!=obs[i].nobs)
        mexErrMsgTxt("Dimension mismatch between dimension of cells in 'y' and 'timeidx'");
     obs[i].tidx = mat2intsm(M);
     if(samples<cvget(obs[i].tidx,obs[i].nobs-1))
         samples=cvget(obs[i].tidx,obs[i].nobs-1);
  }
  
  /* Convert Sw */
  a = 3;
  if(!mxIsCell(prhs[a]))
     mexErrMsgTxt("Argument 'Sw' must be a cell array");
  if(mxGetM(prhs[a])!=1 || mxGetN(prhs[a])!=streams)
     mexErrMsgTxt("'Sw' must have the same dimension as 'y'");

  /* Extract each 'Sw' matrix from cell array */
  for(i=0;i<streams;i++){
     M = mxGetCell(prhs[a],i);
     if (mxGetN(M)!=mxGetM(M))
        mexErrMsgTxt("Cell in 'Sw' not quadratic");
     obs[i].Sw = mat2sm(M);
     obs[i].nw = mxGetN(M);
  }
  

  /* Convert u */
  a = 4;
  if (mxGetN(prhs[a])==0 || mxGetM(prhs[a])==0){
     u = mmake(1,1);
     u->row = 0;
  }
  else{
     u = mat2sm(prhs[a]);
     samples = mxGetM(prhs[a]);
  }


  /* Convert optpar */
  opt = (optpar*) malloc(sizeof(optpar)); /* Allocate mem for par structure */
  opt->Aflag=0; opt->Fflag=0;
  if (nrhs==8){
    a  = 7;
    Matmatrix = mxGetField(prhs[a], 0, "init");
    if(Matmatrix==NULL){
       opt->init = mmake(1,1);
       minit(opt->init);
    }
    else
       opt->init = mat2sm(Matmatrix);
       
	  /* Explore if linear terms are present */
	  /* Relationship between new and past states linear */
	  Matmatrix = mxGetField(prhs[a], 0, "A");
     if(Matmatrix!=NULL){
		  if(mxGetM(Matmatrix)!=nx || mxGetN(Matmatrix)!=nx)
			  mexErrMsgTxt("optpar.A has the wrong dimension");
        opt->A     = mat2sm(Matmatrix);
        opt->Aflag = 1;
     }

     /* Relationship between states and process noise is linear */
	  Matmatrix = mxGetField(prhs[a], 0, "F");
     if(Matmatrix!=NULL){
		  if(mxGetM(Matmatrix)!=nx || mxGetN(Matmatrix)!=getrows(Sv))
			  mexErrMsgTxt("optpar.F has the wrong dimension");
        opt->F     = mat2sm(Matmatrix);
        opt->Fflag = 1;
     }
	  
	  /* Initialize C matrices if present */
     Matmatrix = mxGetField(prhs[a], 0, "C");
	  for(i=0;i<streams;i++)          /* By default, initialize Cflags=0 */
        obs[i].Cflag = 0;
	  if(Matmatrix!=NULL){
        if(!mxIsCell(Matmatrix))
           mexErrMsgTxt("Argument 'opt.C' must be a cell array");
        for(i=0;i<streams;i++){
			  M = mxGetCell(Matmatrix,i);
           if(mxGetM(M)!=0 && mxGetN(M)!=0){
				  if((mxGetM(M)!=obs[i].ny) || (mxGetN(M)!=nx))
					  mexErrMsgTxt("Wrong dimension of a matrix in 'opt.C'");
				  else{
					  obs[i].C = mat2sm(M);
					  obs[i].Cflag = 1;
				  }
			  }
		  }
	  }

	  /* Initialize G matrices if present */
     Matmatrix = mxGetField(prhs[a], 0, "G");
	  for(i=0;i<streams;i++)          /* By default, initialize Gflags=0 */
        obs[i].Gflag = 0;
	  if(Matmatrix!=NULL){
        if(!mxIsCell(Matmatrix))
           mexErrMsgTxt("Argument 'opt.G' must be a cell array");
        for(i=0;i<streams;i++){
			  M = mxGetCell(Matmatrix,i);
           if(mxGetM(M)!=0 && mxGetN(M)!=0){
				  if((mxGetM(M)!=obs[i].ny) || (mxGetN(M)!=obs[i].nw))
					  mexErrMsgTxt("Wrong dimension of a matrix in 'opt.G'");
				  else{
					  obs[i].G = mat2sm(M);
					  obs[i].Gflag = 1;
				  }
			  }
		  }
	  }
  }
  else{
     opt->init = mmake(1,1);
     minit(opt->init);
	  for(i=0;i<streams;i++)          /* By default, initialize Cflags=0 */
        obs[i].Cflag = 0;
	  for(i=0;i<streams;i++)          /* By default, initialize Gflags=0 */
        obs[i].Gflag = 0;
  }


  /* Allocate memory for output matrices */
  xhat_data = mmake(samples+1,nx);
  Smat      = mmake(samples+1,floor(0.5*(nx*(nx+1))+0.5));



  /*
   >>>>>>>>>>>>>>>>>>>>>>         CALL THE C-ROUTINE         <<<<<<<<<<<<<<<<<<<<<
   */
  dd2filtm(XFUNC,YFUNC, xhat_data, Smat, xbar, Sxbar, Sv, u, obs, streams,opt);


  /*
   >>>>>>>>>>>>>>>>>>>         CREATE OUTPUT MATICES            <<<<<<<<<<<<<<<<<<
   */
  if(nlhs>0){
     plhs[0] = mxCreateDoubleMatrix(getrows(xhat_data),nx,mxREAL);
     sm2mat(plhs[0],xhat_data);
  }

  if(nlhs>1){
     plhs[1] = mxCreateDoubleMatrix(getrows(Smat),getcols(Smat),mxREAL);
     sm2mat(plhs[1],Smat);
  }

  /*
   >>>>>>>>>>>>>>>>>>>>        FREE ARGUMENT MATRICES        <<<<<<<<<<<<<<<<<<<<<
   */
  mfree(xbar); mfree(Sxbar); mfree(Sv); mfree(u);
  if(opt->Aflag) mfree(opt->A);
  if(opt->Fflag) mfree(opt->F);
  mfree(opt->init); free(opt); free(obs);
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区黄色| 制服丝袜国产精品| 国产视频一区二区三区在线观看| 午夜精彩视频在线观看不卡| 欧美四级电影网| 亚洲综合色丁香婷婷六月图片| 成人激情小说乱人伦| 欧美激情一区二区| 成人免费看视频| 日韩美女视频一区二区| 国产福利91精品| 国产精品电影院| 色综合视频在线观看| 国产精品国产馆在线真实露脸| 99视频一区二区| 亚洲三级理论片| 欧美日韩一区高清| 日本va欧美va精品| 国产日产欧产精品推荐色| 国产午夜精品理论片a级大结局 | 成人黄色777网| 欧美精品一区二区蜜臀亚洲| 国产一区二区三区日韩| 久久久不卡网国产精品一区| 成人精品小蝌蚪| 夜夜精品浪潮av一区二区三区| 色88888久久久久久影院按摩| 亚洲午夜免费视频| 日韩精品中文字幕一区二区三区| 国产裸体歌舞团一区二区| 欧美激情艳妇裸体舞| 欧美无乱码久久久免费午夜一区| 亚洲色图制服诱惑 | 成人av网址在线| 亚洲人妖av一区二区| 精品一区二区三区在线播放视频 | 精品一区二区三区香蕉蜜桃| 日韩一级免费一区| 国产福利一区二区三区视频| 亚洲精品五月天| 欧美大白屁股肥臀xxxxxx| 成人综合在线网站| 天天射综合影视| 亚洲一区二区三区中文字幕在线| 欧美一区二区女人| 北岛玲一区二区三区四区 | 亚洲桃色在线一区| 91麻豆精品国产91久久久久久久久 | 成人激情小说乱人伦| 一区二区三区**美女毛片| 337p亚洲精品色噜噜噜| 成人午夜av电影| 另类人妖一区二区av| 亚洲欧美日韩久久| 精品久久久久久久人人人人传媒 | 欧美国产精品一区| 色先锋aa成人| 精品一区二区三区在线播放| 一区二区三区在线播放| 国产亚洲欧美中文| 91麻豆精品国产91| 色999日韩国产欧美一区二区| 国产精品一线二线三线| 亚洲成av人在线观看| 椎名由奈av一区二区三区| 精品捆绑美女sm三区| 欧美精品 日韩| 成人av在线一区二区三区| 蜜臀a∨国产成人精品| 亚洲国产一区二区视频| www国产成人| 欧美日韩大陆一区二区| 91美女片黄在线观看91美女| 高清国产一区二区| 理论电影国产精品| 亚洲成av人片| 亚洲成人综合在线| 亚洲激情自拍视频| 国产馆精品极品| 亚洲精品免费在线播放| 久久电影网电视剧免费观看| 久久网这里都是精品| 91精品国产aⅴ一区二区| 欧美在线免费观看视频| 色噜噜夜夜夜综合网| 91网站在线观看视频| 国产成人自拍在线| 国产黄色成人av| 国产成人自拍网| 成人晚上爱看视频| 成人av午夜电影| 91亚洲国产成人精品一区二区三| 另类小说视频一区二区| 久久超碰97人人做人人爱| 麻豆一区二区在线| 精品一区二区三区在线播放视频 | 韩国成人在线视频| 日本不卡中文字幕| 免费高清不卡av| 国产综合久久久久久久久久久久| 久久成人av少妇免费| 精品在线观看免费| 国产九色精品成人porny| 亚洲国产精品自拍| 欧美一级片免费看| av一区二区久久| 色婷婷久久久亚洲一区二区三区| 日本福利一区二区| 欧美久久一二区| 欧美xxxxx牲另类人与| 久久久精品欧美丰满| 亚洲国产精华液网站w| 樱花草国产18久久久久| 午夜av一区二区| 国产乱人伦偷精品视频不卡| 高清不卡一区二区在线| 国产1区2区3区精品美女| 粉嫩蜜臀av国产精品网站| 色综合一个色综合亚洲| 6080日韩午夜伦伦午夜伦| 精品国产sm最大网站| 国产精品家庭影院| 五月天中文字幕一区二区| 国产一区二区三区久久悠悠色av| 成人晚上爱看视频| 欧美日韩成人在线| 国产欧美精品一区二区三区四区 | 香蕉久久夜色精品国产使用方法| 中文字幕免费观看一区| 久久婷婷国产综合精品青草| 国产精品短视频| 亚洲二区在线视频| 国产成人av电影在线| 色播五月激情综合网| 欧美mv日韩mv| 国产精品人成在线观看免费| 亚洲国产精品尤物yw在线观看| 国产欧美日韩在线观看| 国产精品一区二区x88av| 国产美女精品人人做人人爽| 国产日韩在线不卡| 免费在线观看视频一区| 久久这里只精品最新地址| 91成人免费在线视频| 91啦中文在线观看| 8x8x8国产精品| 久久天天做天天爱综合色| 中文字幕一区二区在线观看 | 三级在线观看一区二区| 风间由美中文字幕在线看视频国产欧美 | 国产毛片一区二区| 欧美人与z0zoxxxx视频| 中文字幕在线观看不卡| 久久精品国产第一区二区三区| 在线观看亚洲成人| 日本一区二区综合亚洲| 韩国一区二区在线观看| 欧美日韩你懂得| 一区二区在线观看免费 | 国产精品久久久久久久久果冻传媒 | 欧美一区永久视频免费观看| 亚洲第一主播视频| 欧美午夜理伦三级在线观看| 午夜精品久久久久| 欧美一区二区三区思思人 | 精品国产一区二区精华| 亚洲成人资源网| 欧美日韩在线三级| 午夜av电影一区| 欧美久久久久久久久久| 日韩成人免费在线| 欧美肥妇bbw| 久久国产尿小便嘘嘘| 久久精品亚洲一区二区三区浴池| 国产精品综合二区| 中文字幕日韩av资源站| 91国偷自产一区二区开放时间| 亚洲在线视频网站| 91精品欧美一区二区三区综合在 | 亚洲成人免费在线| 日韩欧美国产综合在线一区二区三区| 蜜臀久久久久久久| 精品精品欲导航| 成人性生交大片| 亚洲免费电影在线| 欧美日韩高清在线播放| 久久精品国产久精国产| 国产女同互慰高潮91漫画| 91女神在线视频| 91精品综合久久久久久| 国产乱对白刺激视频不卡| 国产欧美久久久精品影院| 91蜜桃网址入口| 免费在线看一区| 国产精品美女久久久久久久网站| 99re热视频这里只精品| 五月开心婷婷久久| 国产欧美一区二区三区在线老狼| 色欲综合视频天天天| 免费欧美在线视频|