[QT][MATLAB ENGINE] MATLAB Engine avec Qt
J'ai essayé d'appeler un script Matlab depuis QT Creator , j'ai cherché sur Internet et j'ai trouvé que je dois utiliser Engine Matlab pour faire la liaison entre les 2 , en commençant par inclure la bibliothèque libeng et libmx dans le fichier .pro :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| SOURCES += \
main.cpp
QT += widgets
QT += gui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../Desktop/Engine/ -llibeng
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../Desktop/Engine/ -llibengd
INCLUDEPATH += $$PWD/../../Desktop/Engine/include
DEPENDPATH += $$PWD/../../Desktop/Engine/include
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../Desktop/Engine/ -llibmx
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../Desktop/Engine/ -llibmxd
INCLUDEPATH += $$PWD/../../Desktop/Engine/include
DEPENDPATH += $$PWD/../../Desktop/Engine/include |
Après j'ai suivi un Tutorial qui montre comment appelant un script Matlab depuis QT Creator :
fichier main.cpp :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| #include<iostream>
#include<cmath>
#include "engine.h"
using namespace std;
int main(){
Engine *ep = engOpen(NULL);
double x[1000];
double y[1000];
double z[1000];
double t = 0;
const double dt = 0.001;
int i,j;
double a,b;
mxArray *z_array = mxCreateDoubleMatrix(1000,1,mxREAL);
mxArray *a_array = mxCreateDoubleMatrix( 1,1,mxREAL);
mxArray *b_array = mxCreateDoubleMatrix( 1,1,mxREAL);
double *pz = mxGetPr(z_array);
double *pa = mxGetPr(a_array);
double *pb = mxGetPr(b_array);
for (i=0;i<1000;i++){
//x[i] = cos(2*M_PI*t);
//y[i] = sin(2*M_PI*t);
t+=dt;
}
a = 1;
b = 0;
for (j=0;j<100;j++){
for(i=0;i<1000;i++){
z[i] = a*x[i] + b*y[i];
pz[i] = z[i];
}
pa[0] = a;
pb[0] = b;
engPutVariable(ep,"z",z_array);
engPutVariable(ep,"a",a_array);
engPutVariable(ep,"b",b_array);
engEvalString(ep,"testPlot");
a = a - 0.01;
b = b + 0.01;
}
engClose(ep);
return 0;
} |
fichier testPlot.m :
Code:
1 2 3 4 5 6
|
plot(Z);
axis ([0 1000 -1 1]);
grid on ;
title(sprintf('a = %0.3f \t b = %0.3f ',a,b));
pause(0.1); |
et j'obtiens toujours le message d'erreur suivvant :
Citation:
cannot find -llibengd
Citation:
cannot find -llibmxd
qui montre que le compilateur n'arrive pas accéder aux bibliothèques , sachant que sur QT je compile avec mingw 32bits et et j'ai un matlab 64 bits est ce que le problème vient de celle-la ? en toutes les cas merci d'avance de m'aider puisque je galère avec cela ça fait 3 jours sans résultat