Jump to content
  • Advertisement
Sign in to follow this  
akira32

function is matlab provide for VC++ to process the multiply of two matrices.

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Which name of function do I call for multiply two matrices in VC++? The function is matlab provide for VC++ to process the multiply of two matrices. void CMatlab_MatrixDlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here mxArray* mx1=mxCreateCellMatrix(3,3); mxArray* mx2=mxCreateCellMatrix(3,3); int a[9]; int b[9]; for (int i=0;i<9;i++) { a=i; b=i+1; } mxSetData(mx1,a); mxSetData(mx2,b); int* c; c=(int*)mxGetData(mx1); }

Share this post


Link to post
Share on other sites
Advertisement
I don't think there are any functions to perform calculations on the matrices in the API, only to manipulate the matrix objects. If you're calling this from a mex-function, make a call to Matlab and let it do the calculations. If it's a stand alone application, I believe you have to start the Matlab engine and do the same (the engine is sort of already running when calling it from a mex-function, since you call it from within Matlab) as if it was a mex-function.

Make a call to Matlab with mexCallMATLAB and call the mtimes function.

mxArray *in[2] = {mx1, mx2};
mxArray *out;

mexCallMATLAB(2, in, 1 &out, "mtimes");

That said, I don't think your code is correct, because you're filling a cell matrix with integer values. A cell is another mxArray pointer, not a numerical value.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!