Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.48 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Engine functions: Calling MATLAB from a C application
  2. #include "engine.h"
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6.  
  7. int main()
  8. {
  9.   Engine *ep;
  10.  
  11.   if (!(ep = engOpen(""))) {
  12.     fprintf(stderr, "nCan't start MATLAB enginen");
  13.     return EXIT_FAILURE;
  14.   }
  15.  
  16.   engOutputBuffer(ep, NULL, 0);
  17.  
  18.   engEvalString(ep, "a = 1");
  19.  
  20.   engClose(ep);
  21.   return EXIT_SUCCESS;
  22. }
  23.        
  24. char engOutput[300];
  25. engOutputBuffer(ep, engOutput, 300);
  26.  
  27. engEvalString(ep, "disp('test')");