Matlab Engine Does not print
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi All,
I have written the following code in Visual C++ 2012 to use Matlab engine by modifying the engwindemo.c code.
#######################################################################
int main (int argc, char *argv[]){ printf("Debjit Pal.\n");
Engine *MyMatlabEngine;
if (!(MyMatlabEngine = engOpen(NULL))) { MessageBox ((HWND)NULL, (LPSTR)"Can't start MATLAB engine", (LPSTR) "Engwindemo.c", MB_OK); exit(-1); }
mxArray *xVal = NULL, *yVal = NULL, *d = NULL; double time[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; xVal = mxCreateDoubleMatrix(1, 10, mxREAL); memcpy((char *) mxGetPr(xVal), (char *) time, 10*sizeof(double));
engPutVariable(MyMatlabEngine, "xVal", xVal); engEvalString(MyMatlabEngine, "PI = 3.14; D = .5.*(-9.8).*xVal.^2; P = PI*.5.*(-1.2).*xVal.^3;"); //engEvalString(MyMatlabEngine, "D = .5.*(-9.8).*xVal.^2;"); //engEvalString(MyMatlabEngine, "P = PI*.5.*(-1.2).*xVal.^3;"); engEvalString(MyMatlabEngine, "Handle = figure;"); engEvalString(MyMatlabEngine, "plot(xVal,D);"); engEvalString(MyMatlabEngine, "hold on;"); engEvalString(MyMatlabEngine, "plot(xVal,P);"); engEvalString(MyMatlabEngine, "grid on;"); engEvalString(MyMatlabEngine, "title('Position vs. Time for a falling object');"); engEvalString(MyMatlabEngine, "xlabel('Time (seconds)');"); engEvalString(MyMatlabEngine, "ylabel('Position (meters)');"); engEvalString(MyMatlabEngine, "print(Handle, '-dpdf', 'MyFig.pdf');");
mxDestroyArray(xVal); engClose(MyMatlabEngine);
return 0; }
##################################################################
But what I see that no MyFig.pdf file is being generated. Can anyone suggest what I am missing here? Does all the commands of Matlab works with Matkab Engine interface?
Thanks and Regards,
Debjit.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu External Language Interfaces finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!