I have a C++ Windows Program and I want to convert and visualize some data from this C++ app in an existing Matlab Program.
Currently I am writing the data from the C++ app into files. At the same time the Matlab app reads the files and processes the data. (polling) It basically works but I am running in performance troubles when the data load gets to high.
What is the best solution to transfer data between this programs? I am thinking of a kind of message queue or socket interface.
Click the close button on the MATLAB® desktop. Click. on the left side of the desktop title bar and select Close. Type quit or exit at the command prompt.
To stop execution of a MATLAB® command, press Ctrl+C or Ctrl+Break. On Apple Macintosh platforms, you also can use Command+. (the Command key and the period key).
Much more. Matlab is an abbreviation of C++ is an object-oriented as Matrix Laboratory, which is a well as a general-purpose high-performance language. programming language. Scientists and engineers use it for technical computing in 2D and 3D form.
Use the Matlab API to send your data from C++ to Matlab, then execute a plot command on it. Roughly, do the following -- there are no error checks, but the gist is there:
#include <engine.h>
//open the engine
Engine *m_engine;
m_engine = engOpen("\0");
//put our data
//pretend this is a 2 column, n row matrix, so we can do a 2D plot
mxArray* mx = mxCreateDoubleMatrix(mat->n_rows, mat->n_cols, mxREAL);
memcpy(mxGetPr(mx),some_data,data->n_elem*sizeof(double));
put("data",mx);
mxDestroyArray(mx);
//plot
engEvalString(m_engine, "plot(data(:,1),data(:,2),'-o')");
Just remember, Matlab works in column major, while C++ is row major.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With