[Solved] Running MATLAB in QTGUI

Hi, every one....
In my project I want to run MATLAB program in my GUI. In MATLAB the program is like reading data from some Address location and that data will be displayed(plotting the waveform). In my searching I get 2 solutions 1). Using QProcess function calling the MATLAB program
2). Using MATLAB Engine library in GUI code,I am confused with these two things which one suits for my Project.
If any one knows please help me

If you have enough time and skills the second way is the best (least overhead, maximum compatibility with matlab).
Using QProcess is like your GUI mimic user interaction with matlab console. That is you have to send properformatted matlab script through QProcess to matlab executable and then read response from it (also processing string data).
Using QProcess allows you to pin octave egine instead of matlab. QtOctave is an example.

Thank you for the reply.
Can you give any example code for thisbq. Using QProcess is like your GUI mimic user interaction with matlab console.
I didn't get this one Could you explain me

 I never worked with that. you should search in matlab documentation.
 "QProcess":http://qtproject.org/doc/qt4.8/qprocess.html is well documented. There is example for synchronous execution.
You can write some warrper to manage asynchronous calls and responses.
@class MatLabProc
{
QProcess proc;enum State {IDLE, ERROR, CALCSIN, ...};
State state;public:
MatLabProc() {
state = IDLE;
}//start process
bool start() {
proc.start("matlab.exe");
return proc.waitForStarted();
}//stop process
bool stop() {...}bool calcSin(const QVector<double> & vec) {
if (state != IDLE) return false;
state = CALCSIN;QByteArray script = "clear;\n"
"x = [.. create from vec ...];\n"
"y = sin(x);\n"
"y\n";proc.write(script);
proc.closeWriteChannel();
connect(&proc, SIGNAL(readyReadStandardOutput()), SLOT(sin_stream()));
connect(&proc, SIGNAL(readyReadStandardError()), SLOT(sin_err()));return true;
}signals:
void sinFinished(QVector<double> data);private slots:
void sin_stream() {
/* Ouptut like this
y =Columns 1 through 6:
1.5932e01 7.9915e02 3.9989e02 1.9999e02 1.3000e02 6.9999e03
Columns 7 through 10:
4.0000e03 2.0000e03 1.0000e03 8.0000e04
*/
if (proc.canReadLine()) {
QByteArray data = proc.readAllStandardOutput();
//read numbers from data
if (.. 10 number read ..) {
proc.closeReadChannel();
proc.disconnect();
state = IDLE;
emit sinFinished(vecOfSinResults);
}
}}
void sin_err() {
if (proc.canReadLine()) {
QByteArray data = proc.readAllStandardError();
//process errors in data
proc.closeReadChannel();
proc.disconnect();
state = ERROR;
}
}
};@

Thank you, I will try my level best, If I get any doubts I will post again. sorry can you give any example code for calling MATLAB engine function from QTCreator
And I have one doubt regarding MATLAB engine, if I use this in QT, It will execute only Matlab commands or it will run the Matlab.exe file?
Because I want to Plot the waveforms of some data using Matlab & It is running from GUI. and I found that this MATLAB engine is called from C/C++ files or from visual studio only.
Is it possible to call from QT GUI programming

Running matlab engine examples:
"YouTube video":http://www.youtube.com/watch?v=3zdVQf1MotY (plotting example)
"Presentation about matlab API":http://goo.gl/jwFYaIf you use QProcess than matlab will run as separate process. If you use offical c++ API propably too (I'm not sure).
bq. Is it possible to call from QT GUI programming
Yes, the plots will pop up in separate windows (in matlab's figure plotting tool). If you want to integrate plots with Qt Gui forms then i suggest you to use "Qwt library":http://qwt.sourceforge.net/ .

bq. and I found that this MATLAB engine is called from C/C++ files or from visual studio only.
matab only ships liberties compatible with visual studio compiler so you hawe to use qt sdk compiled with vs2010.

hi thank you for giving reply.
plotting from matlab and qt is different. Both of having in my project. I am using QProcess now. If I get any difficulties when I will testing the project I will modify the code