Matrix is close to singular or badly scaled. Results may be inaccurate solution ??

Hello, i try to solve a linear system, connecting c++ with matlab like this:
mxArray *Am = NULL;
Am = mxCreateDoubleMatrix (matrixSize, matrixSize, mxREAL);
memcpy( ( void* )mxGetPr(Am) , ( void* )Ac[0] , matrixSize * matrixSize * sizeof(double));
mxArray *Bm = NULL;
Bm = mxCreateDoubleMatrix (matrixSize, 1, mxREAL);
memcpy( ( void* )mxGetPr(Bm) , ( void* )Bc , matrixSize * sizeof(double) );
mxArray *Rm = NULL;
Rm = mxCreateDoubleMatrix (matrixSize, 1, mxREAL);
engPutVariable(ep, "Am",Am);
engPutVariable(ep, "Bm",Bm);
engPutVariable(ep, "Rm",Rm);
engEvalString (ep, "Rm = linsolve(Am,Bm);");
And i get the warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.665335e-017.
Now this is an issue of singular matrix. However if i give the two arrays by hand in matlab's workspace the linear system is solved with no warnings.
Any ideas? thank you all

Answers (0)

Categories

Asked:

on 6 Aug 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!