当前位置: 首页>>代码示例>>C++>>正文


C++ engEvalString函数代码示例

本文整理汇总了C++中engEvalString函数的典型用法代码示例。如果您正苦于以下问题:C++ engEvalString函数的具体用法?C++ engEvalString怎么用?C++ engEvalString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了engEvalString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LatexInsert3DPlot

void LatexInsert3DPlot(klMatrix<double>& mat, ofstream &_tex, string dir,string filename,string title,klHoldOnStatus holdon,const char* markerType)
{
	klMatlabEngineThreadMap klmtm;
	Engine* matlabEngine=klmtm.find(klThread<klMutex>::getCurrentThreadId() );
	char* arg = new char[2048];
	char* evalString = new char[2048];
	sprintf(arg,"%s//%s.eps",dir.c_str(),filename.c_str());

	const char* xAxis=NULL;
	const char* yAxis=NULL;
	const char* zAxis=NULL;
	bool useExtents=true;
	
	klScatterPlot3D(mat,filename.c_str(),title.c_str(), xAxis, yAxis,zAxis, useExtents, holdon, markerType);

	if(holdon==klHoldOnStatus::LastPlot  || holdon==klHoldOnStatus::NoHold )
	{
		sprintf(evalString,"print -r1200 -depsc %s;",arg);
		engEvalString(matlabEngine, evalString);

		engEvalString(matlabEngine, "hold off;close(gcf);");

		sprintf(evalString,"epstopdf   %s",arg);

		system(evalString);
		sprintf(arg,"%s.pdf",filename.c_str());
		_tex<<"\\includegraphics[width=10.0cm,height=10.0cm]{"<<arg<<"}"<<endl<<endl;
	}
	delete arg;
	delete evalString;
}
开发者ID:wavescholar,项目名称:klMatrixCore,代码行数:31,代码来源:kl_latex_helper_fns.cpp

示例2: main

int main(int argc, const char *argv[])

{
  Engine *ep;
  char buff[10240];
  int i;

  /* matlab must be in the PATH! */
  if (!(ep = engOpen("matlab -nodisplay"))) {
    fprintf(stderr, "Can't start MATLAB engine\n");
    return -1;
  }
  engOutputBuffer(ep, buff, 10239);

  /* load the mex file */
  if(argc<2){
    fprintf(stderr, "Error. Give full path to the MEX file as input parameter.\n");
    return -1;
  }
  void *handle = dlopen(argv[1], RTLD_NOW);
  if(!handle){
    fprintf(stderr, "Error loading MEX file: %s\n", strerror(errno));
    return -1;
  }

  /* grab mexFunction handle */
  mexFunction_t mexfunction = (mexFunction_t)dlsym(handle, "mexFunction");
  if(!mexfunction){
    fprintf(stderr, "MEX file does not contain mexFunction\n");
    return -1;
  }

  /* load input data - for convenience do that using MATLAB engine */
  /* NOTE: parameters are MEX-file specific, so one has to modify this*/
  /* to fit particular needs */
  engEvalString(ep, "load input.mat");
  mxArray *arg1 = engGetVariable(ep, "im1");
  mxArray *arg2 = engGetVariable(ep, "im2");
  mxArray *arg3 = engGetVariable(ep, "szx");
  mxArray *arg4 = engGetVariable(ep, "szy");
  mxArray *arg5 = engGetVariable(ep, "ngh");
  mxArray *pargout[1] = {0};
  const mxArray *pargin[5] = {arg1, arg2,arg3, arg4,arg5};

  /* execute the mex function */
  mexfunction(1, pargout, 5, pargin);

  /* print the results using MATLAB engine */
  engPutVariable(ep, "result", pargout[0]);
  engEvalString(ep, "result");
  printf("%s\n", buff);

  /* cleanup */
  mxDestroyArray(pargout[0]);
  engEvalString(ep, "clear all;");
  dlclose(handle);
  engClose(ep);

  return 0;
}
开发者ID:kristinbranson,项目名称:JAABA,代码行数:60,代码来源:test.c

示例3: LatexInsertHistogram

void LatexInsertHistogram(klVector<double>& vec, unsigned int numBins,ofstream &_tex, string dir,string filename,string title)
{
	/*vec.setupRange();
	klVector<double> hist=vec.histogram(numBins,vec.y0,vec.y1);
	hist.setupRange();
	hist.setupDomain(vec.y0,vec.y1);*/

	klMatlabEngineThreadMap klmtm;
	Engine* matlabEngine=klmtm.find(klThread<klMutex>::getCurrentThreadId() );
	char* arg = new char[2048];
	char* evalString = new char[2048];
	sprintf(arg,"%s\\%s.eps",dir.c_str(),filename.c_str());
	
	//klPlot1D<double>(hist,arg,title.c_str());

	klPlotHistogram<double>(vec,arg,title.c_str());
		
	sprintf(evalString,"print -r1200 -depsc %s;",arg);
	engEvalString(matlabEngine, evalString);
	engEvalString(matlabEngine, "hold off;close(gcf);");
	sprintf(evalString,"epstopdf   %s",arg);
	system(evalString);
	sprintf(arg,"%s.pdf",filename.c_str());
	_tex<<"\\includegraphics[width=10.0cm,height=10.0cm]{"<<arg<<"}"<<endl<<endl;
	delete arg;
	delete evalString;
}
开发者ID:wavescholar,项目名称:klMatrixCore,代码行数:27,代码来源:kl_latex_helper_fns.cpp

示例4: Eval

bool Eval(Engine *ep, char *out, const char *cmd, ...) {

    char buf[BUFSIZE];
    va_list args;
    va_start(args, cmd);
    vsprintf(buf, cmd, args);
    va_end(args);

    engEvalString(ep, "clear engerr; lasterr('');");

    engEvalString(ep, buf);
    printf("%s", out);

    engEvalString(ep, "engerr = lasterr;");

    mxArray *err = engGetVariable(ep, "engerr");
    if (err == NULL) {
        printf("unable to retrieve variable 'engerr'\n\n");
        return false;
    }
    bool ok = (mxGetNumberOfElements(err) == 0);
    mxDestroyArray(err);

    return ok;

}
开发者ID:haishanwu,项目名称:cnpkg,代码行数:26,代码来源:demoeng.cpp

示例5: engOpen

    void MatlabAdapter::initModel()
    {
        mEngine = engOpen(mEngineArgs.size() ?  mEngineArgs.toStdString().c_str(): "\0");
        engOutputBuffer(mEngine, mBuffer, mBufferSize);

        if(mEngine == 0)
        {
            TRACE("warning: connection failed!");
        }

        const QString modelDir = "cd '" +  mWorkingDir + "/Projects/MMM" + "'";
        TRACE("working dir is: %s", modelDir.toStdString().c_str());

        int retVal = 0;
        retVal += engEvalString(mEngine, modelDir.toStdString().c_str());
        retVal += engEvalString(mEngine, "initializeModelAdapter");

        // *************** read out dofs ****************************
        retVal += engEvalString(mEngine, "numDOFs = length(Model.q0);");
        mxArray* mxNumDOFs = 0;

        if((mxNumDOFs =engGetVariable(mEngine, "numDOFs")) == 0)
        {
            TRACE("WARNING: can't evaluate degrees of freedom");
            mxDestroyArray(mxNumDOFs);
            return;
        }

        tree.dofs.resize(static_cast<int>(mxGetPr(mxNumDOFs)[0]));
        TRACE("model has %lu degrees of freedom", tree.dofs.size());

        // ************** read out segment / joint information *************
        retVal += engEvalString(mEngine, "numSegs = size(Model.Body,2);");
        retVal += engEvalString(mEngine, "numJoints = size(Model.Joint,2);");
        mxArray *mxNumSegs = 0, *mxNumJoints = 0;

        if((mxNumSegs =engGetVariable(mEngine, "numSegs")) == 0) {
            TRACE("WARNING: can't evaluate number of segments");
            mxDestroyArray(mxNumSegs);
            return;
        }

        if((mxNumJoints =engGetVariable(mEngine, "numJoints")) == 0) {
            TRACE("WARNING: can't evaluate number of joints");
            mxDestroyArray(mxNumJoints);
            return;
        }
        tree.jointNodes.resize(static_cast<int>(mxGetPr(mxNumJoints)[0]));
        tree.partNodes.resize(static_cast<int>(mxGetPr(mxNumSegs)[0]));
        //model.numJoints = static_cast<int>(mxGetPr(mxNumJoints)[0]);
        //model.numSegments = static_cast<int>(mxGetPr(mxNumSegs)[0]);

        mxDestroyArray(mxNumDOFs);
        mxDestroyArray(mxNumJoints);
        mxDestroyArray(mxNumSegs);

    }
开发者ID:benknopp,项目名称:wombat,代码行数:57,代码来源:MatlabAdapter.cpp

示例6: engEvalString

WaveData SignalProcessTools::waveRead(string filename)
{
	engEvalString(ep, ("[R,Fs]=audioread('"+filename+"');").c_str());
	engEvalString(ep, "R=R(:,1);");
	WaveData data;
	getVector(data.wave, "R");
	mxArray *Fs = engGetVariable(ep, "Fs");
	data.sampleRate = (int)mxGetPr(Fs)[0];
	return data;
}
开发者ID:anxuthu,项目名称:signalandsystemProject,代码行数:10,代码来源:SignalProcessTools.cpp

示例7: putVector

void SignalProcessTools::plot(vector dataX, vector dataY, \
							  string title, string xLabel, string yLabel)
{
	putVector(dataX, "X");
	putVector(dataY, "Y");
	engEvalString(ep, "plot(X,Y);");
	if (title != "")  engEvalString(ep, ("title('"+title+"');").c_str());
	if (xLabel != "")  engEvalString(ep, ("xlabel('"+xLabel+"');").c_str());
	if (yLabel != "")  engEvalString(ep, ("ylabel('"+yLabel+"');").c_str());
}
开发者ID:anxuthu,项目名称:signalandsystemProject,代码行数:10,代码来源:SignalProcessTools.cpp

示例8: put2DData

void SignalProcessTools::plotSpec(FreqData data)
{
	int n1 = data.freq.length;
	int n2 = data.time.length;
	put2DData(data.real.data, n1, n2, "BReal");
	put2DData(data.imag.data, n1, n2, "BImag");
	string cmd = "B=BReal+i*BImag;imagesc(time,freq,abs(B));";
	engEvalString(ep, cmd.c_str());
	cmd = "axis('xy');xlabel('ʱ¼ä (Ãë)'); ylabel('ƵÂÊ (Hz)');";
	engEvalString(ep, cmd.c_str());
}
开发者ID:anxuthu,项目名称:signalandsystemProject,代码行数:11,代码来源:SignalProcessTools.cpp

示例9: mlabraw_eval

PyObject * mlabraw_eval(PyObject *, PyObject *args)
{
  //XXX how large should this be?
  const int  BUFSIZE=10000;
  char* fmt = "try, %s; MLABRAW_ERROR_=0; catch, MLABRAW_ERROR_=1; end;";
  char buffer[BUFSIZE];
  char cmd[BUFSIZE];
  char *lStr;
  char *retStr = buffer;
  PyObject *ret;
  PyObject *lHandle;
  if (! PyArg_ParseTuple(args, "Os:eval", &lHandle, &lStr)) return NULL;
  if (! PyCObject_Check(lHandle)) {
    PyErr_SetString(PyExc_TypeError, "Invalid object passed as mlabraw session handle");
    return NULL;
  }
  sprintf(cmd, fmt, lStr); //FIXME check buffer overflow
  // std::cout << "DEBUG: CMD " << cmd << std::endl << std::flush; 
  engOutputBuffer((Engine *)PyCObject_AsVoidPtr(lHandle), retStr, BUFSIZE-1);
  if (engEvalString((Engine *)PyCObject_AsVoidPtr(lHandle), cmd) != 0) {
    PyErr_SetString(mlabraw_error, 
                   "Unable to evaluate string in MATLAB(TM) workspace");
    return NULL;
  }
  {
    mxArray *lArray = NULL; 
    char buffer2[BUFSIZE];
    char *retStr2 = buffer2;
    bool __mlabraw_error;
    if (NULL == (lArray = _getMatlabVar(lHandle, "MLABRAW_ERROR_")) ) {
      PyErr_SetString(mlabraw_error, 
                      "Something VERY BAD happened whilst trying to evaluate string " 
                      "in MATLAB(TM) workspace.");
      return NULL;
    }
    __mlabraw_error = (bool)*mxGetPr(lArray);
    mxDestroyArray(lArray);
    if (__mlabraw_error) {
      engOutputBuffer((Engine *)PyCObject_AsVoidPtr(lHandle), retStr2, BUFSIZE-1);
      if (engEvalString((Engine *)PyCObject_AsVoidPtr(lHandle), 
                        "disp(subsref(lasterror(),struct('type','.','subs','message')))") != 0) {
        PyErr_SetString(mlabraw_error, "THIS SHOULD NOT HAVE HAPPENED!!!");
        return NULL;
      }
      PyErr_SetString(mlabraw_error, retStr2 + ((strncmp(">> ", retStr2, 3) == 0) ?  3 : 0));
      return NULL;
    }
  }
  if (strncmp(">> ", retStr, 3) == 0) { retStr += 3; } //FIXME
  ret = (PyObject *)PyString_FromString(retStr);
  return ret;
}
开发者ID:bh0085,项目名称:programming,代码行数:52,代码来源:mlabraw.cpp

示例10: engEvalString

    void MatlabAdapter::initGenCoords()
    {
        engEvalString(mEngine, "coordNames = {Model.GenCoor.Name}");
        engEvalString(mEngine, "coordRanges = [ Model.lb; Model.ub]");

        mxArray *mxNames = engGetVariable(mEngine, "coordNames");
        mxArray *mxRanges = engGetVariable(mEngine, "coordRanges");

        double* values = mxGetPr(mxRanges);
        double min, max, stepSize;

        unsigned size = tree.dofs.size();
        for(unsigned i=0; i < size; i++)
        {
            mxArray *mxCell = mxGetCell(mxNames, i);
            char* name = mxArrayToString(mxCell);

            min = values[i];
            max = values[i+size];
            stepSize = (max-min) / 100.0;
            if(stepSize > 0.05) stepSize = 0.05;

            DegreeOfFreedom dof(min, max, 0, stepSize);
            dof.name = name;

            if(dof.name.size() > 6)
            {
            	if(dof.name.substr(0,6).compare("root_r") == 0)
            	{
            		TRACE("limited");
            		dof.rangeType = DegreeOfFreedom::limitedRange;
            		dof.min = -5;
            		dof.max = 5;
            	} else
            	{
            		TRACE("circular");
            		dof.rangeType = DegreeOfFreedom::circularRange;
            		dof.min = - M_PI;
            		dof.max = + M_PI;
            	}
            }

            tree.dofs.at(i)=dof;
            TRACE("generalized coordinat %s @ %i : min %f to %f", name, i, min, max);
        }


        mxDestroyArray(mxNames);
        mxDestroyArray(mxRanges);
    }
开发者ID:benknopp,项目名称:wombat,代码行数:50,代码来源:MatlabAdapter.cpp

示例11: MessageBox

MATLABPLOTTER::MATLABPLOTTER()
{
	//stuff	
	// Start the MATLAB engine 
	
	if (!(ep = engOpen(NULL))) {
		MessageBox ((HWND)NULL, (LPSTR)"Can't start MATLAB engine", 
			(LPSTR) "Matlab.cpp", MB_OK);
		exit(-1);
	}
	engEvalString(ep, "iter=1;");
	engEvalString(ep, "color_codes=['r' 'g' 'b' 'k' 'y'];");
	

}
开发者ID:jasonhogan,项目名称:sti-deprecated,代码行数:15,代码来源:Matlab.cpp

示例12: calloc

void MATLABPLOTTER::plotfreqscan(std::vector <double> &FREQ_vector, std::vector <double> &DAQ_vector)
{
	
	mxArray *data_freq = NULL;
	mxArray *data_DAQ = NULL;
		//Scan laser


		double *freq_data_ptr = (double*) calloc(FREQ_vector.size(), sizeof(double));
		if (freq_data_ptr==NULL) exit(1);
		double *DAQ_data_ptr = (double*) calloc(DAQ_vector.size(), sizeof(double));
		if (DAQ_data_ptr==NULL) exit(1);

	for(unsigned int i=0;i < DAQ_vector.size(); i++) {
		double stra = FREQ_vector.at(i);
		
		double strb = DAQ_vector.at(i);
		freq_data_ptr[i] = stra;
		DAQ_data_ptr[i] = strb;
		}


	data_freq = mxCreateDoubleMatrix(1, FREQ_vector.size(), mxREAL);
	memcpy((char*) mxGetPr(data_freq), freq_data_ptr, FREQ_vector.size()*sizeof(double));

	data_DAQ = mxCreateDoubleMatrix(1, FREQ_vector.size(), mxREAL);
	memcpy((char*) mxGetPr(data_DAQ), DAQ_data_ptr, FREQ_vector.size()*sizeof(double));

	/*
	 * Place the variable dataFreq & dataDAQ into the MATLAB workspace
	 */

	engPutVariable(ep, "dataFreq", data_freq);
	engPutVariable(ep, "dataDAQ", data_DAQ);

	/* Plot the result
	 */
	//engEvalString(ep, "hold on;");
	engEvalString(ep, "figure(1);");
	engEvalString(ep, "plot(dataFreq(:)',dataDAQ(:)');");
	engEvalString(ep, "title('Rb Scan');");
	engEvalString(ep, "xlabel('Frequency (GHz)');");
	engEvalString(ep, "ylabel('Absorbtion (V)');");

	free(DAQ_data_ptr);
	free(freq_data_ptr);

}
开发者ID:jasonhogan,项目名称:sti-deprecated,代码行数:48,代码来源:Matlab.cpp

示例13: engOpen

void Uav::initializeMatlabEngine()
{
  matlabEngine = engOpen(NULL);
    
  if( !matlabEngine )
  { qCritical("%s : Cannot open the MATLAB engine.",
                objectName().toStdString().c_str() ); }; 
                
 
  // prepare an empty matrix to hold the ownship's track
  engEvalString(matlabEngine, "ownshipTrack = [];");
  
  // prepare a plot figure to show that track
  engEvalString(matlabEngine, "figure('Name','UAV Track');");
  engEvalString(matlabEngine, "axis equal;");
}
开发者ID:mvsframework,项目名称:mvs,代码行数:16,代码来源:uav.cpp

示例14: executeCommand

void MatLabEngine::executeCommand( const std::string &command, const bool unchecked ) {

	if ( _matLabLogFileStreamPtr ) {
		std::cerr << command << std::endl;
		(*_matLabLogFileStreamPtr) << "try\n\t" << command << "\nend" << std::endl;
	}

	if (  engEvalString( _ep, command.c_str() )  !=  0  ) {
		_ep = 0;
		throw MatLabUdm::Exception( "MatLab connection lost." );
	}

	_matLabOutput = getBuffer();
	if (  _matLabOutput.find( "???" ) == 0  ) {
#ifdef _DEBUG
	// KMS: is there a better way to check for an error???
		std::string error = "Executing MatLab command '";
		error += command + "' resulted in error '" + _matLabOutput;
		if (!unchecked) {
#ifdef _WIN32
			OutputDebugString(error.c_str());
			DebugBreak();
#endif
			throw MatLabUdm::Exception(error);
		} else {
#ifdef _WIN32
			OutputDebugString(error.c_str());
#endif
		}
#endif
	}

}
开发者ID:pombreda,项目名称:metamorphosys-desktop,代码行数:33,代码来源:MatLabEngine.cpp

示例15: while

int
MatlabEvaluator::runAnalysis(const Vector &x)
{	
	
	// Let's just make a direct call since we have the pointer to OpenSees domain
	// This replaces above call to Tcl command; however, in the reset command
	// revertToStart() is also called on theTransientIntegrator -- MHS needs to check
	if (theOpenSeesDomain->revertToStart() != 0) {
		opserr << "ERROR MatlabEvaluator -- error in resetting Domain" << endln;
		return -1;
	}
	
	// Put random variables into the structural domain according to the RandomVariablePositioners
	int rvIndex;
	RandomVariablePositionerIter rvPosIter = theReliabilityDomain->getRandomVariablePositioners();
	RandomVariablePositioner *theRVPos;
	while ((theRVPos = rvPosIter()) != 0) {
		rvIndex = theRVPos->getRvIndex();
		theRVPos->update(x(rvIndex));
	}
	
	// Start a Matlab engine
	Engine *ep;
	ep = engOpen("\0");
	
	// Execute a Matlab function called 'matlabgfun'
	char theMatlabCommand[50];
	sprintf(theMatlabCommand,"matlabgfun");
	engEvalString(ep, theMatlabCommand);
	
	// Shut down the Matlab engine
	engClose(ep);
	
	return 0;
}
开发者ID:DBorello,项目名称:OpenSees,代码行数:35,代码来源:MatlabEvaluator.cpp


注:本文中的engEvalString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。