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

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

?? dd1magv.c

?? 卡爾曼濾波
?? C
字號:
/***********************************************************************
 * MEX TEMPLATE FOR DD1M-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_dd1m.c kalmlblx.o    % PC/Linux, gcc
 *   >> mex my_dd1m.c kalmlblcc.obj % Matlab lcc compiler
 *
 ***********************************************************************/
#define KALMFILE "agvfctm.c"
#define XFUNC agvtu
#define YFUNC agvobs
/***********************************************************************/

/*
 *     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 dd1filtm(int (*xfct)(matrix*, matrix*, matrix*, matrix*, int),
            int (*yfct)(matrix*, matrix*, matrix*, int),
	    matrix*, matrix*, matrix*, matrix*, matrix*, matrix*, 
            obsstruct*, int, optpar*);

#include KALMFILE

/*********************************************************************************
 *                                                                               *
 *    dd1mc gateway routine                                                      *
 *    ---------------------                                                      *
 *                                                                               *
 *    This is a C-version of the Matlab function 'dd1m'.                         *
 *    Type 'help dd1m' 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         <<<<<<<<<<<<<<<<<<<<<
   */
  dd1filtm(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
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91色在线porny| 日韩欧美一区中文| 日韩一区二区不卡| 中文字幕亚洲欧美在线不卡| 亚洲高清在线视频| 国产精品羞羞答答xxdd| 欧美日韩高清在线播放| 国产精品美女久久久久av爽李琼| 丝袜美腿一区二区三区| 成人精品国产福利| 日韩限制级电影在线观看| 亚洲激情六月丁香| 国产精品亚洲午夜一区二区三区| 日韩一级欧美一级| 亚洲午夜激情av| 99热在这里有精品免费| 久久免费电影网| 免费成人美女在线观看.| 欧美色综合网站| 亚洲同性gay激情无套| 国产一级精品在线| 日韩视频123| 日本三级亚洲精品| 91麻豆精品国产91| 亚洲成av人片在www色猫咪| 91影院在线观看| 国产精品免费免费| 国产91丝袜在线播放0| 久久夜色精品国产噜噜av| 日韩电影在线看| 欧美精品久久99| 图片区日韩欧美亚洲| 欧美喷潮久久久xxxxx| 亚洲sss视频在线视频| 在线欧美小视频| 亚洲综合图片区| 欧美伊人久久大香线蕉综合69| 国产精品久久精品日日| 成人中文字幕合集| 国产精品水嫩水嫩| 99热99精品| 亚洲免费av观看| 一本到不卡免费一区二区| 亚洲欧美日韩电影| 欧美亚洲动漫制服丝袜| 亚洲电影在线播放| 欧美福利一区二区| 精品中文av资源站在线观看| 欧美成人三级在线| 国产黑丝在线一区二区三区| 国产日韩高清在线| 色婷婷久久综合| 偷拍与自拍一区| 欧美va日韩va| 国产成人亚洲精品狼色在线| 国产精品久久久久aaaa樱花| 色婷婷综合久久久中文字幕| 亚洲va国产天堂va久久en| 欧美va亚洲va| 91免费观看在线| 日韩中文字幕av电影| 日韩视频在线一区二区| 久久99精品久久久久婷婷| 国产精品亲子乱子伦xxxx裸| 日本韩国精品一区二区在线观看| 午夜激情一区二区| 久久无码av三级| 色琪琪一区二区三区亚洲区| 亚洲国产精品天堂| 在线欧美一区二区| 国产一区二区导航在线播放| 亚洲激情自拍偷拍| 久久影视一区二区| 欧美日韩在线综合| 成人免费毛片aaaaa**| 性做久久久久久久久| 国产精品免费人成网站| 欧美精品v国产精品v日韩精品| 国产美女精品在线| 亚洲国产日韩a在线播放性色| 久久综合九色综合97婷婷| 91福利视频网站| 国产成人精品三级| 美腿丝袜亚洲三区| 亚洲免费观看在线观看| 精品国产一区二区三区忘忧草| 在线一区二区观看| 国产91清纯白嫩初高中在线观看| 日韩成人免费电影| 亚洲精品视频在线观看网站| 亚洲精品在线免费播放| 欧美日韩国产一区| 91蝌蚪porny九色| 国产成人8x视频一区二区| 秋霞电影一区二区| 亚洲一区在线观看免费观看电影高清| 久久久噜噜噜久久中文字幕色伊伊| 欧美日韩中文精品| 91视视频在线观看入口直接观看www | 狠狠色综合色综合网络| 亚洲一区二区影院| 日韩理论片一区二区| 中文字幕国产一区| 精品久久国产97色综合| 欧美一区二区人人喊爽| 欧美日韩精品一区二区三区四区 | 欧美日韩国产精品成人| 色综合欧美在线| 成人av资源下载| 国产福利电影一区二区三区| 蜜桃精品视频在线观看| 日韩电影在线一区| 亚洲福利视频一区| 日韩国产精品久久久| 青娱乐精品视频在线| 亚洲第一会所有码转帖| 无码av中文一区二区三区桃花岛| 亚洲国产成人tv| 亚洲成人tv网| 琪琪久久久久日韩精品| 久久精品国产网站| 久久精品国产免费看久久精品| 欧美丰满高潮xxxx喷水动漫| 在线成人免费视频| 亚洲欧洲av在线| 欧美精品高清视频| 欧美一级片在线看| 欧美一二三四区在线| 337p日本欧洲亚洲大胆精品| www亚洲一区| 欧美国产日产图区| 亚洲久本草在线中文字幕| 亚洲欧美日韩成人高清在线一区| 日韩理论片在线| 天天色天天爱天天射综合| 日本人妖一区二区| 国产成人综合网站| 91捆绑美女网站| 欧美一级日韩免费不卡| 中文字幕乱码亚洲精品一区 | 盗摄精品av一区二区三区| 国产高清在线精品| 成人精品gif动图一区| 欧美视频一区二区三区四区| 在线观看视频一区二区欧美日韩 | 亚洲日本在线视频观看| 亚洲永久精品国产| 亚洲va国产天堂va久久en| 偷拍与自拍一区| 国产美女在线精品| 在线观看视频欧美| 欧美一区二区免费视频| 久久这里都是精品| 中文字幕视频一区二区三区久| 午夜国产精品影院在线观看| 久久国产日韩欧美精品| 国产1区2区3区精品美女| caoporn国产一区二区| 91麻豆免费看| 欧美日韩国产首页| 精品国产乱码久久久久久浪潮| 国产视频不卡一区| 精品免费国产一区二区三区四区| 亚洲欧美偷拍卡通变态| 日韩av午夜在线观看| 国产成人在线看| 99久久99久久精品免费看蜜桃| 欧美电视剧免费全集观看| 中文字幕欧美日本乱码一线二线| 樱花草国产18久久久久| 老司机精品视频在线| 色欲综合视频天天天| 日韩欧美www| 一区二区三区精品在线| 久久精品国产秦先生| 69堂国产成人免费视频| 国产精品视频免费| 丝袜美腿亚洲综合| 成人自拍视频在线观看| 精品福利二区三区| 亚洲一区二区影院| 国产69精品久久777的优势| 欧美电影在哪看比较好| 亚洲国产精品二十页| 免费在线观看成人| 日本高清不卡一区| 亚洲天堂2014| 粉嫩av一区二区三区粉嫩| 制服丝袜日韩国产| 亚洲综合色丁香婷婷六月图片| av电影一区二区| 精品99999| 奇米色一区二区三区四区| 欧美日韩一级二级| 亚洲欧美日本韩国| 波多野结衣中文一区| 国产日韩欧美a| 精品一区二区精品| 69精品人人人人| 午夜视频在线观看一区二区 |