Results 1 to 3 of 3

Thread: invoking Matlb through QT

  1. #1
    Join Date
    May 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy invoking Matlb through QT

    Hi,

    I am trying to invoke matlab using the QProcess class, however, it is not working.
    Each time matlab is invoked, it flashes for a second and dissapears. There are no such
    issues while invoking other processes such as emacs, Firefox etc.
    Please help.
    Thanks.

    int main(int argc, char *argv[]) {

    QApplication app(argc, argv);
    QStringList argo, list;
    QProcess exec;
    argo<<"-nojvm -nosplash -r 'addmatrix(2,7)'";
    exec.start("matlab", argo);
    return app.exec();
    }

  2. #2
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: invoking Matlb through QT

    I seem to recall that anything following the run (-r) option had to be in double quotes. This may be your problem.

    Have you tried starting matlab without any arguments?
    Qt Code:
    1. exec.start("matlab")
    To copy to clipboard, switch view to plain text mode 
    Got to keep the loonies on the path ...

  3. #3
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: invoking Matlb through QT

    Here is how I got this to work:
    link the following matlab libs:

    LIBS += -L "c:/Program Files/MATLAB/R2007b/bin/win32" \
    -leng -lmat -lmex -lmwblas -lmwlapack -lmwmathutil -lmx -ldfblas -ldflapack

    Then in your program, invoke the engine like so:
    Qt Code:
    1. #include <engine.h>
    2. ....
    3. Engine *ep = engOpen(NULL);
    4. QString tmp = QString("numcycles = 0;");
    5. engEvalString(ep,tmp.toStdString().c_str());
    To copy to clipboard, switch view to plain text mode 

    you can also work with arrays and variables - consult the matlab documentation and search for engGetVariable and engPutVariable

    good luck

Similar Threads

  1. Invoking a QFileDialog from another dialog
    By skimpax in forum Qt Programming
    Replies: 2
    Last Post: 24th March 2010, 17:16
  2. Invoking New Dialog
    By kb1lqc in forum Qt Programming
    Replies: 8
    Last Post: 5th November 2009, 15:23
  3. invoking microsoft word from qt
    By omprakash in forum Qt Programming
    Replies: 2
    Last Post: 31st October 2007, 20:43
  4. Invoking QT Docking widget from MFC MDI application
    By Vikram in forum Qt Programming
    Replies: 1
    Last Post: 7th July 2007, 18:26
  5. Invoking a browser...???
    By deepusrp in forum Newbie
    Replies: 4
    Last Post: 12th June 2007, 17:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.