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

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

?? sfanfis.c

?? 模糊控制工具箱,很好用的,有相應的說明文件,希望對大家有用!
?? C
字號:
/* Copyright 1994-2002 The MathWorks, Inc.  */
/* $Revision: $  $Date: $  */

/*
 * Syntax  [sys,x0]=sffis(t,x,u,flag,FISMATRIX,LAMBDA_SS,SAMPLE_TIME)
 */

/* S function for ANFIS block - Developed as part of Fuzzy 2.0, but never shipped */

#define S_FUNCTION_NAME sfanfis

#include <stdio.h>     /* needed for declaration of sprintf */
#include <stdlib.h>	/* needed for declaration of calloc */

#ifdef MATLAB_MEX_FILE
#include "mex.h"      /* needed for declaration of mexErrMsgTxt */
#endif

/* for RTW */
#ifndef MATLAB_MEX_FILE
/*
 * The following only applies to MATLAB 4.2c and before.  Because 'cg_matrix.h'
 * was not up todate, these definitions were added.  Once the header file is
 * complete in V5, we shouldn't need these.  If for some reason these are
 * needed for V5, 'mxGetScalar is defined properly.  'mxCreateString' is not.
 * For one, 'mxCreateFull' doesn't exist and two even if it did, we don't
 * create strings in V5 this way anymore. 
 *
 * I've commented out the following so that this will compile under V5 strict
 * compliance.  Once this is resolved, this comment should be removed.
 *
 * 07-08-96 : rayn
 */
/* The followings are not supported by RTW. */
/* Definitions suggested by Rick Spada */
/*
#define mxGetScalar(mat)     mxGetPr(mat)[0]
#define mxCreateString(str)  (mxArray *)(mxSetPr(mxCreateFull(1,strlen(str),0),str)-2)
*/
#endif

/*
 * need to include simstruc.h for the definition of the SimStruct and
 * its associated macro definitions.
 */
#include "simstruc.h"

/* Include pertinent files */
#include "anfis.h"
#include "lib.c"
#include "mf.c"
#include "t_norm.c"
#include "defuzz.c"
#include "callml.c"
#include "list.c"
#include "list2.c"
#include "evaluate.c"
#include "dmf_dp.c"
#include "nodefun.c"
#include "datstruc.c"
#include "debug.c"
#include "io.c"
#include "kalman.c"
#include "stepsize.c"
#include "learning.c"
#include "fismat.c"
#include "c2matlab.c"

#define FISMATRIX	ssGetArg(S,0)
#define LAMBDA_SS	ssGetArg(S,1)	/* lambda and step size */
#define SAMPLE_TIME	ssGetArg(S,2)
#define OUT_FIS_NAME	ssGetArg(S,3)

/*
 * mdlInitializeSizes - initialize the sizes array
 */
static void
mdlInitializeSizes(SimStruct *S)
{
	DOUBLE *tmp;
	int in_n, out_n;

	/*
	mexPrintf("lambda = %g\n", mxGetPr(LAMBDA_SS)[0]);
	mexPrintf("ss = %g\n", mxGetPr(LAMBDA_SS)[1]);
	mexPrintf("sample time = %g\n", mxGetScalar(SAMPLE_TIME));
	*/
	if (ssGetNumArgs(S) == 4) {
		tmp = mxGetPr(FISMATRIX);
		in_n = tmp[2];
		out_n = tmp[2+mxGetM(FISMATRIX)];
		ssSetNumContStates(S, 0);	/* no. of continuous states */
		/* keep a dummy state */
		ssSetNumDiscStates(S, 1);	/* no. of discrete states */
		ssSetNumInputs(S, 2*in_n+out_n);/* no. of inputs */
		ssSetNumOutputs(S, out_n);	/* no. of outputs */
		ssSetDirectFeedThrough(S, 1);	/* direct feedthrough flag */
		ssSetNumSampleTimes(S, 1);	/* no. of sample times */
		ssSetNumInputArgs(S, 4);	/* no. of input arguments */
		ssSetNumRWork(S, 0);	/* no. of real work vector elements */
		ssSetNumIWork(S, 0);	/* no. of int. work vector elements */
		ssSetNumPWork(S, 1);	/* no. of ptr. work vector elements */
					/* This is the FIS pointer */
	} else {
#ifdef MATLAB_MEX_FILE
	    mexErrMsgTxt("Wrong number of additional inputs.");
#endif
	}
}

/*
 * mdlInitializeSampleTimes - initialize the sample times array
 *
 * This function is used to specify the sample time(s) for your S-function.
 * If your S-function is continuous, you must specify a sample time of 0.0.
 * Sample times must be registered in ascending order.
 */
static void
mdlInitializeSampleTimes(SimStruct *S)
{
	/* argument right after S is the index */
	ssSetSampleTimeEvent(S, 0, mxGetScalar(SAMPLE_TIME));
	ssSetOffsetTimeEvent(S, 0, 0.0);
}

/*
 * mdlInitializeConditions - initialize the states
 *
 * In this function, you should initialize the continuous and discrete
 * states for your S-function block.  The initial states are placed
 * in the x0 variable.  You can also perform any other initialization
 * activities that your S-function may require.
 */
static void
mdlInitializeConditions(DOUBLE *x0, SimStruct *S)
{
	static int count = 0;
	DOUBLE **fismatrix;
	int m, n, i, j;
	FIS *fis;

	/* put FISMATRIX into proper format */
	m = mxGetM(FISMATRIX);
	n = mxGetN(FISMATRIX);
	fismatrix = (DOUBLE **)fisCreateMatrix(m, n, sizeof(DOUBLE));
	for (i = 0; i < m; i++)
		for (j = 0; j < n; j++)
			fismatrix[i][j] = mxGetPr(FISMATRIX)[j*m + i]; 

	/* Create FIS node */
	fis = (FIS *)fisCalloc(1, sizeof(FIS));
	fisBuildFisNode(fis, fismatrix, n);

	/* Place fismatrix in the data strucutre */
	/* This is good for spit final output FISMAT */
	fis->in_fismat = fismatrix;
	fis->m = m;
	fis->n = n;

	/* check if the FIS is suitable for learning */
	anfisCheckFisForLearning(fis);

	/* build ANFIS */
	mexPrintf("Build ANFIS ...\n");
	anfisBuildAnfis(fis);
	anfisAssignForwardFunction(fis);
	fis->next = NULL;

	/* get training parameters */
	fis->lambda =	mxGetPr(LAMBDA_SS)[0];
	fis->ss =	mxGetPr(LAMBDA_SS)[1];

	anfisSetVariable1(fis);
	anfisInitialMessage1(fis);
	anfisKalman(fis, 1);	/* reset matrices used in kalman */

	/* Set fis as the Pwork for this S function */
	ssGetPWork(S)[0] = fis;

	/* dummy state */
	x0[0] = 0;
}

/*
 * mdlOutputs - compute the outputs (y)
 */
static void
mdlOutputs(DOUBLE *y, DOUBLE *x, DOUBLE *u, SimStruct *S, int tid)
{
	FIS *fis = (FIS *)ssGetPWork(S)[0]; /* obtained from Pwork */
	int j;
	/*
	mexPrintf("In mdlOutputs!\n");
	*/

	/* To get mdlUpdate called, this is the solution 
		suggested by John Ciolfi. */
	/*
	if (ssIsSampleHitEvent(S, 0, tid))
		mdlUpdate(x, u, S, tid);
	*/

	/* Dispatch the inputs */
	for (j = 0; j < fis->in_n; j++)
		fis->node[j]->value = u[j];
	/* ==========
	PRINTARRAY(u, fis->in_n + fis->out_n);
	*/
	/* Compute the output */
	anfisForward(fis, fis->in_n, fis->node_n-1);
	/* Collect the output */
	for (j = 0; j < fis->out_n; j++)
		y[j] = fis->node[fis->node_n-fis->out_n+j]->value;
	/* ==========
	PRINT(fis->node[fis->node_n-1]->value);
	*/
}

/*
 * mdlUpdate - perform action at major integration time step
 *
 * This function is called once for every major integration time step.
 * Discrete states are typically updated here, but this function is useful
 * for performing any tasks that should only take place once per integration
 * step.
 */
static void
mdlUpdate(DOUBLE *x, DOUBLE *u, SimStruct *S, int tid)
{
	FIS *fis = (FIS *)ssGetPWork(S)[0]; /* obtained from Pwork */
	int j;
	/*
	mexPrintf("In mdlUpdate!\n\n");
	*/

	/* dispatch inputs */
	for (j = 0; j < fis->in_n; j++)
		fis->node[j]->value = u[fis->in_n+j];
	/*
	PRINTARRAY(u, 2*(fis->in_n) + fis->out_n);
	*/
	
	/* forward calculation from layer 1 to layer 3 */
	/* The following can be commented out when mdlOutputs is
	called before mdlUpdate, which is usually true in SIMULINK */
	/* For safety, we restored it here */
	anfisForward(fis, fis->in_n, fis->layer[4]->index-1);

	/* prepare i/o pair for RLSE */
	/* The training data pair starts from position fis->in_n */
	anfisGetKalmanDataPair1(fis, u+fis->in_n);

	/* RLSE */
	anfisKalman(fis, 0);	/* normal operation */

	/* put RLSE identified parameters back into ANFIS */
	anfisPutKalmanParameter(fis);

	/* forward pass from layer 4 to 6 */
	anfisForward(fis, fis->layer[4]->index, fis->node_n-1);

	/* dispatch de_do at outputs */
	fis->node[fis->node_n-1]->de_do =
		-2*(u[2*(fis->in_n)] - fis->node[fis->node_n-1]->value);

	/* backward calculation */
	anfisBackward(fis, fis->node_n-2, fis->in_n);

	/* clear up de_dp */
	/* de_do is always cleared in anfisBackward */
	anfisClearDerivative(fis);

	/* update de_dp of layer 1*/
	anfisUpdateDE_DP(fis, fis->in_n,fis->layer[2]->index-1);

	/* update parameters in layer 1*/
	anfisUpdateParameter(fis, fis->in_n, fis->layer[2]->index-1);

	/* dummy update */
	x[0] = u[0];
}

/*
 * mdlDerivatives - compute the derivatives (dx)
 */
static void
mdlDerivatives(DOUBLE *dx, DOUBLE *x, DOUBLE *u, SimStruct *S, int tid)
{
}

/*
 * mdlTerminate - called when the simulation is terminated.
 */
static void
mdlTerminate(SimStruct *S)
{
	FIS *fis = (FIS *)ssGetPWork(S)[0];	/* obtained from Pwork */
	{
	DOUBLE **out_fismat;
	mxArray *OUT_FISMAT;
/*	mxArray *parray; */
	char *out_fis_name;
	int out_fis_name_leng;
	int k;
/*	int ret_val; */
	
	/* redirect parameters */
	/* fis->trn_best_para was used by anfisAnfis2FisMat */
	for (k = 0; k < fis->para_n; k++)
		fis->trn_best_para[k] = fis->para[k];
	out_fismat = fisCopyMatrix(fis->in_fismat, fis->m, fis->n);
	anfisAnfis2FisMat(fis, out_fismat, 0);
	OUT_FISMAT = c2matlab(out_fismat, fis->m, fis->n);
	out_fis_name_leng = mxGetN(OUT_FIS_NAME) + 1;
	out_fis_name = fisCalloc(out_fis_name_leng, sizeof(char));
	mxGetString(OUT_FIS_NAME, out_fis_name, out_fis_name_leng);
	mexPrintf("Write the FIS matrix %s to workspace ...\n", out_fis_name);
	if (mexPutVariable("caller", out_fis_name, OUT_FISMAT) != 0)
		fisError("Cannot create output FIS matrix!\n");
	mxFree(out_fis_name);
	mxDestroyArray(OUT_FISMAT);
	/*
	parray=mxCreateDoubleMatrix(0, 0, mxREAL)
	mxSetM(parray, fis->m);
	mxSetN(parray, fis->n);
	mxSetPr(parray, mxGetPr(OUT_FISMAT);
	mxSetName(parray, "SL_FISMAT");
	ret_val=mexPutArray(parray, "caller");
	mxFree(parray);
	fisFreeMatrix((void **)out_fismat, fis->m);
	mxFree(mxGetPr(OUT_FISMAT));
	*/
	}
	mexPrintf("Destroy ANFIS ...\n");
	fisFreeMatrix((void **)fis->in_fismat, fis->m);
	anfisFreeAnfis(fis);
	fisFreeFisNode(fis);
}

#ifdef	MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区三区免费在线看| 91香蕉视频污| 中文字幕在线一区二区三区| 精品嫩草影院久久| 精品国产三级a在线观看| 日韩视频免费观看高清完整版在线观看| 九九国产精品视频| 国产欧美1区2区3区| 欧美国产日韩在线观看| 国产精品天干天干在线综合| 《视频一区视频二区| 亚洲视频一区在线| 午夜精品一区二区三区免费视频 | 欧美日韩精品高清| 久久99精品国产麻豆婷婷| 不卡一区在线观看| 一本色道久久综合狠狠躁的推荐| 日韩av网站在线观看| 蜜桃精品视频在线| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | av中文字幕不卡| 91啪亚洲精品| 久久久久久久av麻豆果冻| 国产精品久久久久毛片软件| 欧美国产激情一区二区三区蜜月| 国产精品人成在线观看免费| 国产一区欧美二区| 色综合网色综合| 欧美日韩二区三区| 日韩一区二区三区精品视频| 一区二区三区四区蜜桃| 蜜臀av性久久久久蜜臀aⅴ流畅 | 欧美日韩一级片在线观看| 正在播放一区二区| 国产无人区一区二区三区| 亚洲欧美一区二区三区久本道91| 久久日一线二线三线suv| 日本高清无吗v一区| 5月丁香婷婷综合| 亚洲国产成人精品视频| 国产精品中文字幕一区二区三区| 日韩精品乱码免费| 国产不卡视频一区二区三区| 美女久久久精品| 6080亚洲精品一区二区| 天堂精品中文字幕在线| 欧美日本在线观看| 午夜精品一区二区三区免费视频 | 91精品国产麻豆| 日本强好片久久久久久aaa| 欧美大尺度电影在线| 一区二区国产盗摄色噜噜| 91麻豆精品视频| 亚洲综合清纯丝袜自拍| 91日韩在线专区| 日韩欧美一区在线| 精品一区精品二区高清| 欧美激情在线一区二区三区| 99riav一区二区三区| 久久你懂得1024| 99久久伊人久久99| 亚洲超碰精品一区二区| 欧美亚洲高清一区二区三区不卡| 欧美亚洲禁片免费| 日韩成人伦理电影在线观看| 久久久综合精品| 色欧美88888久久久久久影院| 欧美刺激午夜性久久久久久久| 日韩精品一区在线| 国产在线播放一区| 在线免费观看成人短视频| 欧美日韩亚洲丝袜制服| 亚洲6080在线| 欧美日韩精品一区视频| 亚洲精品国产品国语在线app| 中文天堂在线一区| 99re热这里只有精品视频| 亚洲黄网站在线观看| 欧美高清dvd| 国产精品午夜在线| 欧美午夜寂寞影院| 久久国产精品色婷婷| 欧美无乱码久久久免费午夜一区| 国产无人区一区二区三区| 亚洲影院在线观看| 国产喂奶挤奶一区二区三区| 麻豆成人在线观看| 国产精品网曝门| 在线精品视频免费播放| 精品一区二区三区免费| 日韩一区国产二区欧美三区| 国产一区二区三区精品视频 | 蓝色福利精品导航| 久久久99精品久久| 久久精品国产99国产精品| 色综合久久久久久久久| 日本91福利区| 日韩欧美国产三级| 色久综合一二码| 一区精品在线播放| 欧美一区二区三级| www..com久久爱| 精品一区二区久久久| 一区二区三区四区中文字幕| 91小宝寻花一区二区三区| 免费在线观看视频一区| 亚洲男人天堂av| 国产精品全国免费观看高清| 91精品国产91热久久久做人人| 亚洲一二三四久久| 日本一区二区三区免费乱视频| 国内成人精品2018免费看| 欧美性大战xxxxx久久久| 国产99久久久国产精品潘金| 久久新电视剧免费观看| 久久99精品久久久久| 亚洲高清免费一级二级三级| 日本一区二区在线不卡| 91精品国产91久久久久久一区二区 | 亚洲人成网站精品片在线观看| av激情亚洲男人天堂| 国产一区二区在线视频| 免播放器亚洲一区| 三级不卡在线观看| 亚洲一区二区三区中文字幕| 国产日韩欧美a| 中文字幕av一区二区三区免费看| 99精品1区2区| 波多野结衣欧美| 国产99久久久国产精品潘金 | 成人视屏免费看| 亚洲色图视频网| 国产精品久久久久久亚洲伦| 久久先锋影音av鲁色资源| 欧美一级午夜免费电影| 91麻豆精品国产91久久久使用方法 | 亚洲高清免费在线| 亚洲午夜久久久久久久久电影院| 91精品国产91久久久久久最新毛片| 亚洲国产中文字幕在线视频综合| 日韩写真欧美这视频| 欧美久久一区二区| 国产一区 二区 三区一级| 国产乱子轮精品视频| 老司机午夜精品99久久| 蜜臀a∨国产成人精品| 欧美国产一区在线| 欧美国产精品一区| 亚洲人一二三区| 一区二区成人在线观看| 亚洲一区在线免费观看| 视频一区二区欧美| 国产制服丝袜一区| 99re在线精品| 日本精品一区二区三区高清| 色八戒一区二区三区| 欧美高清你懂得| 久久久777精品电影网影网| 国产精品久久久久久久久晋中 | 7777精品伊人久久久大香线蕉的| 国产麻豆视频一区| 99久久精品国产网站| 午夜av一区二区| 狠狠久久亚洲欧美| jizzjizzjizz欧美| 欧美伦理影视网| 久久久久久黄色| 1000部国产精品成人观看| 首页国产欧美久久| 免费在线观看日韩欧美| 成人动漫一区二区三区| 欧美日韩久久一区二区| 欧美激情在线一区二区三区| 欧美成人一级视频| 亚洲女子a中天字幕| 蜜臀国产一区二区三区在线播放| 亚洲综合无码一区二区| 精品亚洲porn| 色综合av在线| 久久综合五月天婷婷伊人| 制服丝袜av成人在线看| 国产欧美日韩卡一| 天堂影院一区二区| 国产黄色成人av| 欧美另类变人与禽xxxxx| 久久久久久久久久电影| 亚洲h动漫在线| 国产69精品久久99不卡| 免费成人你懂的| 色婷婷精品久久二区二区蜜臀av| 国产精品一级片在线观看| 欧美日韩国产一级二级| 国产精品久久久久久久久久久免费看| 久久精品一二三| 亚洲chinese男男1069| 日一区二区三区| 91久久国产综合久久| 国产肉丝袜一区二区| 美女mm1313爽爽久久久蜜臀| 色欧美片视频在线观看在线视频|