I am trying to use matlab engine. I want it do a left division as
following lines
A = mxCreateDoubleMatrix(ROWS,3,mxREAL);//creat and fill in A, y
y = mxCreateDoubleMatrix(ROWS,1,mxREAL);
......//initializes A, y
......//from matlab prompt-line I can see they are all
properly initialized
engEvalString(ep, "x=A\y"); //left division
//from promptline, I cannot see variable 'x', as
a result of the above execution!
x = engGetVariable(ep, "x"); //as a result, this step
returns x=0 !!!
Can anyone tell me what's wrong with this simple use?
Thanks,
Shufei
Subject: left division, engEvalString() does not work?
On May 4, 10:57 am, Vanderbilt <shufei....@gmail.com> wrote:
> Hi,
>
> I am trying to use matlab engine. I want it do a left division as
> following lines
>
> A = mxCreateDoubleMatrix(ROWS,3,mxREAL);//creat and fill in A, y
> y = mxCreateDoubleMatrix(ROWS,1,mxREAL);
> ......//initializes A, y
> ......//from matlab prompt-line I can see they are all
> properly initialized
> engEvalString(ep, "x=A\y"); //left division
> //from promptline, I cannot see variable 'x', as
> a result of the above execution!
> x = engGetVariable(ep, "x"); //as a result, this step
> returns x=0 !!!
>
> Can anyone tell me what's wrong with this simple use?
>
> Thanks,
> Shufei
any ideas?
Still waiting for your input.
Thanks
Subject: left division, engEvalString() does not work?
In article <1178739237.353666.212190@n59g2000hsh.googlegroups.com>,
Vanderbilt <shufei.fan@gmail.com> wrote:
> On May 4, 10:57 am, Vanderbilt <shufei....@gmail.com> wrote:
> > Hi,
> >
> > I am trying to use matlab engine. I want it do a left division as
> > following lines
> >
> > A = mxCreateDoubleMatrix(ROWS,3,mxREAL);//creat and fill in A, y
> > y = mxCreateDoubleMatrix(ROWS,1,mxREAL);
> > ......//initializes A, y
> > ......//from matlab prompt-line I can see they are all
> > properly initialized
> > engEvalString(ep, "x=A\y"); //left division
> > //from promptline, I cannot see variable 'x', as
> > a result of the above execution!
> > x = engGetVariable(ep, "x"); //as a result, this step
> > returns x=0 !!!
> >
> > Can anyone tell me what's wrong with this simple use?
> >
> > Thanks,
> > Shufei
>
> any ideas?
> Still waiting for your input.
> Thanks
-------------------
What value is 'ROWS' set to? You can get zeros in some of the three
elements of x = A\y if 'ROWS' is less than 3. If 'ROWS' is equal to 3, in
general there will be a single exact answer. For larger values of 'ROWS',
you will not in general get exact solutions but only those with least
square error.
Roger Stafford
Subject: left division, engEvalString() does not work?
>
> > any ideas?
> > Still waiting for your input.
> > Thanks
>
> -------------------
> What value is 'ROWS' set to? You can get zeros in some of the three
> elements of x = A\y if 'ROWS' is less than 3. If 'ROWS' is equal to 3, in
> general there will be a single exact answer. For larger values of 'ROWS',
> you will not in general get exact solutions but only those with least
> square error.
>
> Roger Stafford
My ROWS is much larger than 3.
You are right, what I want is an approximate solution, with least
square error.
My problem is not in the correctness of solution. It is that no
solution was returned at all!
( During my debug, After executing the line "engEvalString(ep, "x=A
\y"); //left division ", I try to test it in the matlab workspace,
there were no variable 'x' produced as a result. But, when I input the
command x=A\y at matlab prompt, x was correctly computed! )
I suspect there are some error in the way I use the engine?
Thanks
Shufei
Subject: left division, engEvalString() does not work?
I guess it's a little to late for that question to be
answered, but just in case some one else encounters the
same problem.
Vanderbilt <shufei.fan@gmail.com> wrote in message
<1178290663.323760.120190@y80g2000hsf.googlegroups.com>...
> engEvalString(ep, "x=A\y"); //left division
>
> Can anyone tell me what's wrong with this simple use?
Try "x=A\\y". The backslash is an escape character in
C/C++, you'll have to use '\\' to get an ordinary '\'.
best wishes
Sven
Subject: left division, engEvalString() does not work?
"Sven Fischer" <fisher311-matlab@yahoo.de> wrote in
message <ful499$csk$1@fred.mathworks.com>...
> I guess it's a little to late for that question to be
> answered, but just in case some one else encounters the
> same problem.
>
> Vanderbilt <shufei.fan@gmail.com> wrote in message
>
<1178290663.323760.120190@y80g2000hsf.googlegroups.com>...
> > engEvalString(ep, "x=A\y"); //left division
> >
> > Can anyone tell me what's wrong with this simple use?
>
> Try "x=A\\y". The backslash is an escape character in
> C/C++, you'll have to use '\\' to get an ordinary '\'.
>
> best wishes
> Sven
And an even later suggested option:
engEvalString(ep, "x=mldivide(A,y)");
James Tursa
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.