# 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.

## 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 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.

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
15
5. 5

• 9
• 13
• 9
• 33
• 13
• ### Forum Statistics

• Total Topics
632593
• Total Posts
3007281

×