Sign in to follow this  

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

This topic is 3951 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]=i; b[i]=i+1; } mxSetData(mx1,a); mxSetData(mx2,b); int* c; c=(int*)mxGetData(mx1); }

Share this post


Link to post
Share on other sites
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

This topic is 3951 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this