This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Prompt User for Input

Because MATLAB® does not use stdin and stdout, do not use C/C++ functions like scanf and printf to prompt for user input. The following example shows how to use mexCallMATLAB with the input function to get a number from the user.

#include "mex.h"
#include "string.h"
void mexFunction( int nlhs, mxArray *plhs[],
                  int nrhs, const mxArray *prhs[] )
  mxArray   *new_number, *str;
  double out;

  str = mxCreateString("Enter extension:  ");
  out = mxGetScalar(new_number);
  mexPrintf("You entered: %.0f ", out);

See Also

| |

Related Topics

Was this topic helpful?