MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayMATLAB Central > MATLAB Newsreader > if d = x^2, and x=[0,0;1,0] then why is eval(d) no... 

Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to x^2 From: Don Robison Date: 27 Mar, 2010 19:07:26 Message: 1 of 10 
Hello my name is Don Robison. I am having a problem with the way matlab evaluates expressions. It seems if I put a polynomial on the command prompt and I have declared the variables to be matrices the evaluation will be fine, but if I declare the polynomial to be a symbol then try to evaluate the symbolic expression instead of a literal they are not the same thing. 
Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to x^2 From: us Date: 27 Mar, 2010 19:18:04 Message: 2 of 10 
Don Robison <joe_blow_281@hotmail.com> wrote in message <1111757053.455267.1269716876794.JavaMail.root@gallium.mathforum.org>... 
Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to From: Don Robison Date: 27 Mar, 2010 19:28:58 Message: 3 of 10 
>> syms x 
Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to From: us Date: 27 Mar, 2010 19:58:07 Message: 4 of 10 
Don Robison <joe_blow_281@hotmail.com> wrote in message <1817186076.455340.1269718178462.JavaMail.root@gallium.mathforum.org>... 
Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to From: Don Robison Date: 27 Mar, 2010 20:50:48 Message: 5 of 10 
Hello us. This is Don Robison. Thank you for your help, but the code does not return x^2. I need to evaluate a symbolic expression such as x^i*y^i*z^k, and have the matrix multiplied by itself i,j,k times. The code you gave seems to just return xd without taking it to the second power. 
Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to From: ImageAnalyst Date: 27 Mar, 2010 23:43:37 Message: 6 of 10 
Do you mean to use .^ (dot caret) instead of ^ (caret) to take element 
Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to From: Matt J Date: 27 Mar, 2010 23:52:08 Message: 7 of 10 
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <23cb42470a3e47af90c67889c83e2524@30g2000yqi.googlegroups.com>... 
Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to From: Roger Stafford Date: 27 Mar, 2010 23:54:06 Message: 8 of 10 
Don Robison <joe_blow_281@hotmail.com> wrote in message <1396842502.455793.1269723085870.JavaMail.root@gallium.mathforum.org>... 
Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to From: Matt J Date: 28 Mar, 2010 00:38:05 Message: 9 of 10 
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hom5qu$r3l$1@fred.mathworks.com>... 
Subject: if d = x^2, and x=[0,0;1,0] then why is eval(d) not equal to From: Don Robison Date: 28 Mar, 2010 02:49:44 Message: 10 of 10 
I found something that kinda works, if I change the situation a bit. I just create an mfile called x, and return the matrix from the function x. This gets around the problem of the internal subs function being unable to substitute a matrix in place of a symbolic variable. Of course no symbolic operations can be preformed on the expression anymore, because x is a function now instead of a symbolic variable. 
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.