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


C++ mxArrayToString函数代码示例

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


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

示例1: mexFunction

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    char *pOption = mxArrayToString( prhs[0] );
    if ( pOption )
    {
        std::string option = pOption;
        if ( option == "newRx" )
        {
            createMxArray(plhs[0], 1);
            createMxArray(plhs[1], reinterpret_cast<long int>( new usrplib::Rx() ));
        } else {
            char *error;
            sprintf(error, "Unrecognized option: %s", pOption);
        }
    } else {
        mexErrMsgTxt("Invalid option type! Must be a string.");
    }
}
开发者ID:calebzulawski,项目名称:suwt-matlab,代码行数:18,代码来源:handler.cpp

示例2: FLA_M2C_ConvertAttribute

/* Convert FLAME attributes specified as a string in MATLAB to the numerical values 
   required when calling FLAME C functions. */
int FLA_M2C_ConvertAttribute(const mxArray *mobj) {
  char *attr;
  int value;

  if (!mxIsChar(mobj)) {
    mexErrMsgTxt("Char array expected.");
  }
  else {
    /* Convert to C style string */
    attr = mxArrayToString(mobj);

    if (strcmp(attr, "FLA_NO_TRANSPOSE") == 0)
      value = FLA_NO_TRANSPOSE;
    else if (strcmp(attr, "FLA_TRANSPOSE") == 0)
      value = FLA_TRANSPOSE;
    else if (strcmp(attr, "FLA_CONJUGATE") == 0)
      value = FLA_CONJUGATE;
    else if (strcmp(attr, "FLA_NO_CONJUGATE") == 0)
      value = FLA_NO_CONJUGATE;
    else if (strcmp(attr, "FLA_CONJ_TRANSPOSE") == 0)
      value = FLA_CONJ_TRANSPOSE;
    else if (strcmp(attr, "FLA_LOWER_TRIANGULAR") == 0)
      value = FLA_LOWER_TRIANGULAR;
    else if (strcmp(attr, "FLA_UPPER_TRIANGULAR") == 0)
      value = FLA_UPPER_TRIANGULAR;
    else if (strcmp(attr, "FLA_NONUNIT_DIAG") == 0)
      value = FLA_NONUNIT_DIAG;
    else if (strcmp(attr, "FLA_UNIT_DIAG") == 0)
      value = FLA_UNIT_DIAG;
    else if (strcmp(attr, "FLA_ZERO_DIAG") == 0)
      value = FLA_ZERO_DIAG;
    else if (strcmp(attr, "FLA_LEFT") == 0)
      value = FLA_LEFT;
    else if (strcmp(attr, "FLA_RIGHT") == 0)
      value = FLA_RIGHT;
    else
      value = -1;

    mxFree(attr);
    
    return value;
  }

}
开发者ID:pgawron,项目名称:tlash,代码行数:46,代码来源:FLA_Matlab2C.c

示例3: mexFunction

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    double *data_set = mxGetPr(prhs[0]);
    unsigned dim = mxGetM(prhs[0]);
    unsigned size = mxGetN(prhs[0]);
    double *query_set = mxGetPr(prhs[1]);
    unsigned query_size = mxGetN(prhs[1]);
    double *params = mxGetPr(prhs[2]);
    std::string index = mxArrayToString(prhs[3]);
    plhs[0] = mxCreateDoubleMatrix(int(params[1]), mxGetN(prhs[1]), mxREAL);
    plhs[1] = mxCreateDoubleMatrix(int(params[1]), mxGetN(prhs[1]), mxREAL);
    double *indices = mxGetPr(plhs[0]);
    double *dists = mxGetPr(plhs[1]);
    lshbox::matkdbqLsh mylsh;
    mylsh.init(data_set, dim, size, index, unsigned(params[2]),
               unsigned(params[3]), unsigned(params[4]), unsigned(params[5]));
    mylsh.query(query_set, query_size, indices, dists,
                unsigned(params[0]), unsigned(params[1]));
}
开发者ID:RSIA-LIESMARS-WHU,项目名称:LSHBOX,代码行数:19,代码来源:kdbqlsh_search.cpp

示例4: mexFunction

void 
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
    char *str;
    (void) plhs;      /* unused parameter */

    /* Check for proper number of input and output arguments */    
    if (nrhs != 1) {
        mexErrMsgIdAndTxt( "MATLAB:mexatexit:invalidNumInputs",
                "One input argument required.");
    } 
    if(nlhs > 1){
        mexErrMsgIdAndTxt( "MATLAB:mexatexit:maxrhs",
                "Too many output arguments.");
    }
    if (!(mxIsChar(prhs[0]))){
        mexErrMsgIdAndTxt( "MATLAB:mexatexit:invalidInput",
                "Input must be of type string.\n.");
    }
    
    if (fp==NULL){
	fp = fopen("matlab.data", "w");
	if (fp == NULL){
	    mexErrMsgIdAndTxt( "MATLAB:mexatexit:errorOpeningFile",
                "Could not open file matlab.data."); 
	}
	mexPrintf("Opening file matlab.data.\n");
	
	/* Register an exit function. You should only register the
	   exit function after the file has been opened successfully*/
	mexAtExit(CloseStream);
    }
    /* The user passes a string in prhs[0]; write the string
       to the data file. NOTE: you must free str after it is used */ 
    str=mxArrayToString(prhs[0]);
    if ((size_t)fprintf(fp,"%s\n", str) != strlen(str) +1){
        mxFree(str);
        mexErrMsgIdAndTxt( "MATLAB:mexatexit:errorWritingFile",
                "Could not write data to file.\n");
    }
    mexPrintf("Writing data to file.\n");
    mxFree(str);
} 
开发者ID:Tri-o-copter,项目名称:Brainware,代码行数:43,代码来源:mexatexit.c

示例5: mexFunction

void
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
    int i;
    char *str[100];

    /* Check for proper number of input and output arguments */    
    if (nrhs < 2) {
	mexErrMsgTxt("At least two input arguments required.");
    } 
    if(nlhs > 1){
	mexErrMsgTxt("Too many output arguments.");
    }
    
    for (i=0; i<nrhs; i++){
	/* Check input to be sure it is of type char. */
	if(!mxIsChar(prhs[i])){
	    mexErrMsgTxt("Input must be of type char.");
	}
	/* Copy the string data from prhs and place it into str. */ 
        str[i] = mxArrayToString(prhs[i]); 
    }
    
    /* Create a 2-Dimensional string mxArray with NULL padding. */
    plhs[0]= mxCreateCharMatrixFromStrings(nrhs, (const char **)str); 

    /* If compile with -DSPACE_PADDING, convert NULLs to spaces */
#if defined(SPACE_PADDING)
    {
        int nelem = mxGetNumberOfElements(plhs[0]);
        mxChar *charData = (mxChar *)mxGetData(plhs[0]);
	for(i=0; i < nelem; i++) {
	    if(charData[i] == (mxChar) 0) {
	        charData[i] = (mxChar) ' ';
	    }
	}
    }
#endif
    /* Free the allocated memory */
    for (i=0; i<nrhs; i++){
        mxFree(str[i]); 
    }
}
开发者ID:HULCBio,项目名称:MotionStation,代码行数:43,代码来源:mxcreatecharmatrixfromstr.c

示例6: mexFunction

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {

	// make sure arguments are valid
	if( !CheckArgs( nlhs, nrhs, prhs ) )
	{
		PrintUsage();
		return;
	}

	char* dat_file_path = mxArrayToString( prhs[0] );

	if( dat_file_path == 0 )
	{
		mexPrintf( "dat_file_path needs to be strings!\n" );
		return;
	}

	// load data
	mexPrintf( "loading %s...\n", dat_file_path );
	MRIDataHeader header;
	std::vector<MRIMeasurement> meas_vector;
	if( !SiemensTool::LoadDatFile( dat_file_path, header, meas_vector ) )
		mexErrMsgTxt( "Loading dat file failed!\n" );

	// load measurements
	MRIData mri_data( header.Size(), header.IsComplex() );
	std::vector<MRIMeasurement>::iterator it;
	for( it = meas_vector.begin(); it != meas_vector.end(); it++ )
		if( !it->UnloadData( mri_data ) )
			mexErrMsgTxt( "MRIMasurement::UnloadData failed!\n" );
		
	// export
	plhs[0] = MexData::ExportMexArray( mri_data );

	if( nlhs > 1 )
	{
		mxArray* meas_struct = 0;
		CreateMeasStructure( meas_vector, &meas_struct );
		plhs[1] = meas_struct;
	}

	mexPrintf( "Done!\n" );
}
开发者ID:ashvinkurian,项目名称:GIR,代码行数:43,代码来源:LoadDat.cpp

示例7: mexFunction

void mexFunction( int nlhs, mxArray *plhs[],
                  int nrhs, const mxArray *prhs[])
{
  const mxArray *cmd;
  int i;
  std::string cmdname, errString = "";
  char *tmp = 0;

  /* Check for proper number of arguments. */
  if(nrhs < 2) {
      errString += "At least two input arguments are required.\n";
      goto err_out;
  } else
      cmd = prhs[0];

  if (!mxIsChar(cmd)) {
      errString +=  "First argument must be a string.\n";
      goto err_out;
  }
  if (mxGetM(cmd) != 1) {
      errString += "First argument must be a row vector.\n";
      goto err_out;
  }
  tmp = mxArrayToString(cmd);
  cmdname = tmp;
  mxFree(tmp);
  for (i = 0; i < n_functions; ++i) {
      // try and match cmdname to a command we know about
    if (::strcmpi(functions[i].name, cmdname.c_str()) == 0 ) {
        // a match.., call function for the command, popping off first prhs
        functions[i].func(nlhs, plhs, nrhs-1, prhs+1); // call function by function pointer...
        return;
    }
  }
  if (i == n_functions) { // cmdname didn't match anything we know about
  err_out:
      errString += "Unrecognized CalinsNetMex command.\nMust be one of: ";
      for (int i = 0; i < n_functions; ++i)
          errString += std::string("\n'") + functions[i].name + "'";
      mexErrMsgTxt(errString.c_str());
  }
}
开发者ID:cculianu,项目名称:StimulateOpenGL_II,代码行数:42,代码来源:CalinsNetMex.cpp

示例8: mexFunction

void mexFunction(int nlhs, mxArray *plhs[],
                 int nrhs, const mxArray *prhs[])
{
     char *dir_name;
     struct file *files;
     int nfiles, i;
     const char *field_names[2];

     if (nlhs > 1)
          mexErrMsgTxt("Too many output arguments.");
     
     if (nrhs == 0)
          dir_name = ".";
     else if (nrhs == 1) {
          if (mxIsChar(prhs[0]) != 1)
               mexErrMsgTxt("Input must be a string.");
          if (mxGetM(prhs[0]) != 1)
               mexErrMsgTxt("Input must be a row vector.");
          dir_name = mxArrayToString(prhs[0]);
     } else
          mexErrMsgTxt("Too many input arguments.");

     files = dir(dir_name, &nfiles);

     field_names[0] = "name";
     field_names[1] = "isdir";
     plhs[0] = mxCreateStructMatrix(nfiles, 1, 2, field_names);

     for (i = 0; i < nfiles; i++) {
          mxSetFieldByNumber(plhs[0], i, 0, mxCreateString(files[i].name));
          mxSetFieldByNumber(plhs[0], i, 1,
                             mxCreateLogicalScalar(files[i].is_dir));
     }

     for (i = 0; i < nfiles; i++)
          mxFree(files[i].name);
     mxFree(files);
     if (nrhs > 0)
          mxFree(dir_name);
     return;
}
开发者ID:ewiger,项目名称:CellProfiler1.0,代码行数:41,代码来源:CPdir.c

示例9: mexFunction

// print_msg
void mexFunction(int nlhs, mxArray *plhs[],
                 int nrhs, const mxArray *prhs[])
{
    size_t ncin_ = mxGetScalar(prhs[0]);
    char* pcin_ = mxArrayToString(prhs[1]);
    excentury::STextInterface<excentury::load_mode> XC_LI_(pcin_, ncin_);
    std::string msg; XC_LI_.load(msg);
    XC_LI_.close();

    fprintf(stderr, "%s\n", msg.c_str());

    excentury::STextInterface<excentury::dump_mode> XC_DI_;
    
    XC_DI_.close();
    std::string xc_mex_str_ = XC_DI_.str();
    plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
    double* ncout_ = mxGetPr(plhs[0]);
    ncout_[0] = xc_mex_str_.size();
    plhs[1] = mxCreateString(xc_mex_str_.data());
    mxFree(pcin_);
}
开发者ID:jmlopez-rod,项目名称:excentury,代码行数:22,代码来源:util-print_msg_mex.cpp

示例10: sendString

void sendString(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  NetClient *nc = GetNetClient(nrhs, prhs);
  
  if(nrhs != 2)		mexErrMsgTxt("Two arguments required: handle, string.");
  //if(nlhs < 1) mexErrMsgTxt("One output argument required.");
  if(mxGetClassID(prhs[1]) != mxCHAR_CLASS) 
	  mexErrMsgTxt("Argument 2 must be a string.");

  char *tmp = mxArrayToString(prhs[1]);
  std::string theString (tmp);
  mxFree(tmp);

  try {
    nc->sendString(theString);
  } catch (const SocketException & e) {
    mexWarnMsgTxt(e.why().c_str());
    RETURN_NULL();
  }  
  RETURN(1);
}
开发者ID:AndrewHires,项目名称:Solo,代码行数:21,代码来源:FSMClient.cpp

示例11: mexFunction

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { 
    if (nrhs != 3) {
        mexErrMsgTxt("Must have 3 inputs"); 
    }
    if (nlhs != 0) {
        mexErrMsgTxt("Must have 0 outputs");
    }

    // Read images
    if (!mxIsUint8(prhs[0]) || mxGetNumberOfDimensions(prhs[0]) != 4) {
        mexErrMsgTxt("images must be a 4D uint8 array");
    }
    uint8_t* images = (uint8_t*) mxGetData(prhs[0]);
    const mwSize* images_size = mxGetDimensions(prhs[0]);
    int width = images_size[0];
    int height = images_size[1];
    int num_channels = images_size[2];
    if (num_channels != 3) {
        mexErrMsgTxt("Expected 3 channels for images");
    }
    int num_images = images_size[3];
    int img_length = width * height * num_channels;
    std::cout << "Image info: width: " << width << " height: " << height << " channels: " << num_channels << " num: " << num_images << std::endl;

    // Read serialized triplets
    if (!mxIsInt32(prhs[1]) || mxGetN(prhs[1]) != 1) {
        mexErrMsgTxt("triplets must have type int32 and have 1 column");
    }
    int32_t* serialized_triplets = (int32_t*) mxGetData(prhs[1]);
    int num_examples = mxGetM(prhs[1]);

    // Read db filename
    char* db_filename = mxArrayToString(prhs[2]);
    printf("%s\n", db_filename);

    google::InitGoogleLogging("triplets_to_caffedb");
    process(images, num_images, width, height, serialized_triplets, num_examples, db_filename);
    
    mxFree(db_filename);
}
开发者ID:BrettLL,项目名称:Deep-Metric-Learning-CVPR16,代码行数:40,代码来源:serialized_triplets_to_leveldb.cpp

示例12: mexFunction

/* The gateway function */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    char *problem_suite;
    int findex;
    coco_problem_t *pb = NULL;
    long long *res; 

    /* check for proper number of arguments */
    if(nrhs!=2) {
        mexErrMsgIdAndTxt("cocoSuiteGetProblem:nrhs","Two inputs required.");
    }
    /* get problem_suite */
    problem_suite = mxArrayToString(prhs[0]);
    /* get function_index */
    findex = (int)mxGetScalar(prhs[1]);
    /* call coco_suite_get_problem() */
    pb = coco_suite_get_problem(problem_suite, findex);
    /* prepare the return value */
    plhs[0] = mxCreateNumericMatrix(1, 1 ,mxINT64_CLASS, mxREAL);
    res = (long long *)mxGetData(plhs[0]);
    *res = (long long)pb;   
}
开发者ID:belkhir-nacim,项目名称:numbbo,代码行数:23,代码来源:cocoSuiteGetProblem.c

示例13: mexFunction

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    // Check number of arguments
	if (nlhs != 0 || nrhs != 2)
		mexErrMsgTxt("Unexpected number of arguments.");
    const char* fname = mxArrayToString(prhs[1]);
    if (fname == NULL )
        mexErrMsgTxt("Second input argument expected to be a filename.");
        
    // Parse the object
    std::unique_ptr<json> j(new json);
    recurse_object(prhs[0], *j);
    
    // Write out the file
    std::ofstream fs(fname);
    if (!fs.is_open())
        mexErrMsgTxt("Failed to open file for writing.");
    fs << std::setw(2);
    fs << std::setprecision(17);
    fs << *j << std::endl;
    fs.close();
}
开发者ID:ojwoodford,项目名称:ojwul,代码行数:22,代码来源:json_write.cpp

示例14: getParams

// Get parameters from inputs
int getParams(const int nrhs, const mxArray *prhs[], short& L, unsigned int& maxIter, \
			  short& nRes, string& dist, bool& isVerbose) {
  
  // Get L
  L = (short)mxGetScalar(prhs[2]);
  
  // Get options
  maxIter   = (unsigned int)10000;
  nRes      = (unsigned int)1;
  dist      = "l1";
  isVerbose = true;
    
  if (nrhs >= 4) {
    // Get option "maxIter"
    mxArray* bufMaxIter = mxGetField(prhs[3],0,"maxIter");
    if ( bufMaxIter != NULL )
      maxIter = (unsigned int)mxGetScalar(bufMaxIter);

	// Get option "nRes"
    mxArray* bufRes = mxGetField(prhs[3],0,"nRes");
    if ( bufRes != NULL )
      nRes = (short)mxGetScalar(bufRes);

    // Get option "dist"
    mxArray* bufDist = mxGetField(prhs[3],0,"dist");
    if ( bufDist != NULL )
      dist = mxArrayToString(bufDist);
        
    // Get option "isVerbose"
    mxArray* bufVerb = mxGetField(prhs[3],0,"isVerbose");
    if ( bufVerb != NULL )
      isVerbose = (mxGetScalar(bufVerb) == 1.0f);
  }
    
  // Display
  mexPrintf("+ Load parameters: L=%d, ", L);
  mexPrintf("maxIter=%d, nRes=%d, dist=\"%s\", isVerbose=%d\n", maxIter, nRes, dist.c_str(), isVerbose);
  return 0;
}
开发者ID:kailizhao,项目名称:tcd,代码行数:40,代码来源:tcd.cpp

示例15: mexFunction

void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]) {

	/* Declarations */
	char *filename = NULL;
	
	if (nlhs>0) {
	  mexErrMsgTxt("Bad number of output arguments");
	}
	/* Input */
	switch(nrhs) {
	case 0:
	  break;
	case 1:
	  filename = mxArrayToString(prhs[0]);
	  break;
	default:
	  mexErrMsgTxt("Bad number of arguments");
	}

  /* Register the display functions */
  /* We could set a flag variable to do it only once */
    MPTK_Server_c::get_msg_server()->register_display_function("info_message_display", &msgfunc);
    MPTK_Server_c::get_msg_server()->register_display_function("error_message_display", &msgfunc);
    MPTK_Server_c::get_msg_server()->register_display_function("warning_message_display", &msgfunc);
    MPTK_Server_c::get_msg_server()->register_display_function("progress_message_display", &msgfunc);
    MPTK_Server_c::get_msg_server()->register_display_function("debug_message_display", &msgfunc);


	if (!MPTK_Env_c::get_env()->load_environment_if_needed(filename)) {
	  mexPrintf("Could not load environment");
	  mxFree(filename);
	  mexErrMsgTxt("Aborting");
	} else {
	  mxFree(filename);
	}
	
}
开发者ID:danstowell,项目名称:mptk,代码行数:38,代码来源:loadenv_exp.cpp


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