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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dd1mc.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 compiler
 *   >> mex my_dd1m.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 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);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99免费精品在线观看| 亚洲一区二区四区蜜桃| 蜜臀av亚洲一区中文字幕| 9久草视频在线视频精品| 精品福利av导航| 免费在线观看视频一区| 91久久精品国产91性色tv| 国产精品久久影院| 国产盗摄一区二区| 精品国产1区二区| 激情综合网av| 精品国产乱码久久久久久免费| 午夜成人在线视频| 欧美久久久一区| 日韩高清国产一区在线| 337p亚洲精品色噜噜噜| 日韩精品1区2区3区| 欧美一区二区三区免费大片 | 精品无人码麻豆乱码1区2区 | 国产香蕉久久精品综合网| 久久av老司机精品网站导航| 欧美一区二区三区精品| 日本不卡一区二区| 久久夜色精品国产噜噜av | 4438x成人网最大色成网站| 亚洲国产sm捆绑调教视频| 这里只有精品99re| 国产乱色国产精品免费视频| 欧美国产国产综合| 色哟哟日韩精品| 丝袜美腿成人在线| 久久久久久久一区| 成人v精品蜜桃久久一区| 亚洲一区二区三区四区在线免费观看| 欧美色偷偷大香| 国产在线视频精品一区| 综合久久久久久久| 日韩欧美激情四射| aaa亚洲精品一二三区| 日本不卡一区二区三区高清视频| 国产欧美精品区一区二区三区 | 精品日韩一区二区| 色综合久久综合网欧美综合网| 日韩二区三区四区| 国产精品久久久久久亚洲伦| 欧美三区在线观看| a级精品国产片在线观看| 日本不卡一区二区三区| 1区2区3区欧美| 久久久久久久久久久99999| 欧美在线高清视频| 成人国产精品视频| 狠狠色丁香婷综合久久| 亚洲成人你懂的| 亚洲美女免费视频| 中文一区二区完整视频在线观看 | 一区二区三区四区激情| 精品国产精品网麻豆系列| 欧美日韩国产系列| 91九色最新地址| 91蜜桃在线观看| 成人av综合在线| 成人激情黄色小说| 国产高清不卡一区二区| 国产黄色成人av| 国产一区高清在线| 国产一区二区女| 国产在线视频一区二区三区| 久久精品久久久精品美女| 亚洲sss视频在线视频| 亚洲午夜视频在线| 亚洲无人区一区| 午夜久久久久久久久| 亚洲午夜一区二区三区| 亚洲成人tv网| 免费一级欧美片在线观看| 蜜桃视频一区二区三区| 九九热在线视频观看这里只有精品| 日日摸夜夜添夜夜添精品视频 | 一卡二卡三卡日韩欧美| 亚洲欧美aⅴ...| 亚洲国产精品一区二区久久恐怖片| 亚洲精品国产精华液| 亚洲一区二区三区精品在线| 午夜视频在线观看一区| 日本中文字幕一区| 国产一区二区成人久久免费影院| 国产精品一区三区| 一本一道波多野结衣一区二区 | 亚洲欧美激情插| 视频一区欧美精品| 国产成人免费xxxxxxxx| 色欧美片视频在线观看在线视频| 欧美日韩视频一区二区| 久久精品一区二区| 亚洲综合小说图片| 日本不卡一区二区| 青娱乐精品视频在线| 久久精品一区二区三区不卡牛牛| 中文字幕一区二区三区乱码在线 | 欧美欧美欧美欧美首页| 久久天堂av综合合色蜜桃网| 亚洲激情图片qvod| 激情小说欧美图片| 欧美日韩精品免费| 国产精品国产三级国产普通话三级 | 国产999精品久久久久久| 在线免费av一区| 国产精品三级视频| 久久夜色精品国产噜噜av| 精品日韩一区二区三区| 日韩一区二区在线观看视频播放| 日韩视频在线你懂得| 中文字幕亚洲综合久久菠萝蜜| 午夜久久福利影院| 色哦色哦哦色天天综合| 久久精品亚洲乱码伦伦中文| 日本在线观看不卡视频| 色婷婷综合激情| 国产精品久久久久永久免费观看| 毛片av中文字幕一区二区| 欧美三级日韩三级| 亚洲黄色小说网站| 色综合天天综合给合国产| 狠狠狠色丁香婷婷综合久久五月| 亚洲天堂av一区| 国产精品88888| 国产精品久久99| 处破女av一区二区| 欧美午夜理伦三级在线观看| 精品国产一区二区在线观看| 午夜天堂影视香蕉久久| 精品视频在线免费| 夜色激情一区二区| 欧美性猛交xxxxxx富婆| 97aⅴ精品视频一二三区| 亚洲日本va午夜在线影院| av不卡一区二区三区| 日本欧洲一区二区| 欧美一区二区视频在线观看2022| 日韩国产精品久久| 欧美另类久久久品| 国产宾馆实践打屁股91| 亚洲v中文字幕| 日韩精品最新网址| 久久激情五月婷婷| 国产精品视频在线看| 色88888久久久久久影院按摩| 一区二区三区四区激情| 欧美一卡二卡在线| 丁香桃色午夜亚洲一区二区三区| 亚洲国产精品精华液ab| 老鸭窝一区二区久久精品| 一本久道久久综合中文字幕| 亚洲一二三区不卡| 精品国产一区二区三区久久久蜜月 | 国产精选一区二区三区| 亚洲欧洲中文日韩久久av乱码| 欧美日韩激情一区二区三区| 国产在线播放一区三区四| 亚洲欧美在线视频| 日韩丝袜情趣美女图片| 99精品国产热久久91蜜凸| 老司机一区二区| 亚洲精品伦理在线| 欧美国产日韩亚洲一区| 欧美日韩日日骚| 日韩午夜在线播放| 欧美一级一级性生活免费录像| 成人av网站在线| 日本aⅴ精品一区二区三区| 国产精品久久久久aaaa樱花| 欧美一区二区日韩| 欧美日韩在线综合| 91色.com| 成人国产亚洲欧美成人综合网 | 成人丝袜视频网| 精品一区二区精品| 日本aⅴ免费视频一区二区三区| 亚洲欧美另类小说| 中文字幕日韩精品一区| 久久精品人人做| 久久蜜桃av一区二区天堂| 日韩一区二区三区在线视频| 制服丝袜成人动漫| 欧美日韩国产高清一区二区| 欧美性xxxxxxxx| 欧美色精品天天在线观看视频| 日本道免费精品一区二区三区| 91麻豆swag| 色屁屁一区二区| 欧美私人免费视频| 欧美乱熟臀69xxxxxx| 欧美日韩精品一区二区三区蜜桃| 欧美综合久久久| 制服丝袜在线91| 精品国产免费一区二区三区香蕉 | 欧美自拍丝袜亚洲| 精品国产乱码久久久久久1区2区 | 99国产精品久久久久久久久久|