#include "mex.h" #include "SDModel.h" #include "SDModel_common.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){ /* INPUT: model - pointer to a model X0 - initial state body - body to apply impulse to F - (3x1) vector of impulse magnitude OUTPUT: X_new - new state after impulse */ int i; double *pointer_to_model; SDModel *mod; if(nrhs!=4) mexErrMsgTxt("model_impulse: Wrong number of input arguments"); if ( (pointer_to_model = mxGetPr(prhs[0])) == NULL ) mexErrMsgTxt("model_impulse: Argument 0 is not a valid pointer to an SDModel object\n"); if ( (mod = (SDModel *) ((long) pointer_to_model[0]))== NULL ) mexErrMsgTxt("model_impulse: Argument 0 is not a valid pointer to an SDModel object\n"); if (mxGetM(prhs[1])!=(mod->NQ()+mod->NU()) || mxGetN(prhs[1])!=1) mexErrMsgTxt("model_impulse: Wrong size of input argument 1"); if (mxGetM(prhs[2])!=1 || mxGetN(prhs[2])!=1) mexErrMsgTxt("model_impulse: Wrong size of input argument 2"); if (mxGetM(prhs[3])!=3 || mxGetN(prhs[3])!=1) mexErrMsgTxt("model_impulse: Wrong size of input argument 3"); if (nlhs>1) mexErrMsgTxt("model_impulse: Too many output arguments"); plhs[0] = mxCreateDoubleMatrix(mod->NQ()+mod->NU(),1,mxREAL); mod->sdinit(); impulse_force(mod, mxGetPr(prhs[1]), (int)mxGetScalar(prhs[2]), mxGetPr(prhs[3]), mxGetPr(plhs[0])); }

AltStyle によって変換されたページ (->オリジナル) /