http://nl.mathworks.com/matlabcentral/newsreader/view_thread/294499
MATLAB Central Newsreader  Change symbols back to numbers
Feed for thread: Change symbols back to numbers
enus
©19942017 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://nl.mathworks.com/images/membrane_icon.gif

Thu, 21 Oct 2010 20:33:04 +0000
Change symbols back to numbers
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/294499#789653
Sheida
Hi I am trying to solve an equation (to eventually put in a loop). However, after I take care of the differentiating, I cannot replace the symbols with actual numbers. Could someone please help me? <br>
Here is what my m file looks like: <br>
syms u1 u2<br>
f = [(u1^3)  u2; (u2^3)  u1];<br>
u = [u1;u2];<br>
J = jacobian(f,u);<br>
Ji = inv(J);<br>
b = Ji*f;<br>
u1 = 2;<br>
u2 = 1;<br>
u = u  b<br>
<br>
my result for "u" is:<br>
u =<br>
<br>
u1 + (u1  u2^3)/(9*u1^2*u2^2  1) + (3*u2^2*(u2  u1^3))/(9*u1^2*u2^2  1)<br>
u2 + (u2  u1^3)/(9*u1^2*u2^2  1) + (3*u1^2*(u1  u2^3))/(9*u1^2*u2^2  1)<br>
<br>
I want matlab to replace all u1s with 2 and all u2s with 1. I have been searching for the past couple of hours and have not found anything. It doesn't seem like it is too hard but I just cant figure it out! <br>
Thanks!

Thu, 21 Oct 2010 22:15:07 +0000
Re: Change symbols back to numbers
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/294499#789677
John
"Sheida " <s.d.not.this@gmail.com> wrote in message <i9q820$3h$1@fred.mathworks.com>...<br>
> Hi I am trying to solve an equation (to eventually put in a loop). However, after I take care of the differentiating, I cannot replace the symbols with actual numbers. Could someone please help me? <br>
> Here is what my m file looks like: <br>
> syms u1 u2<br>
> f = [(u1^3)  u2; (u2^3)  u1];<br>
> u = [u1;u2];<br>
> J = jacobian(f,u);<br>
> Ji = inv(J);<br>
> b = Ji*f;<br>
> u1 = 2;<br>
> u2 = 1;<br>
> u = u  b<br>
> <br>
> my result for "u" is:<br>
> u =<br>
> <br>
> u1 + (u1  u2^3)/(9*u1^2*u2^2  1) + (3*u2^2*(u2  u1^3))/(9*u1^2*u2^2  1)<br>
> u2 + (u2  u1^3)/(9*u1^2*u2^2  1) + (3*u1^2*(u1  u2^3))/(9*u1^2*u2^2  1)<br>
> <br>
> I want matlab to replace all u1s with 2 and all u2s with 1. I have been searching for the past couple of hours and have not found anything. It doesn't seem like it is too hard but I just cant figure it out! <br>
> Thanks! <br>
<br>
I dont have the symbolic toolbox but this might work. If you can convert "u" to a character array (im not sure if that is possible at all) then you can regexprep to replace the values you want, then evaluate it with eval also, hope that helps

Thu, 21 Oct 2010 22:28:03 +0000
Re: Change symbols back to numbers
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/294499#789680
John
"John " <jrazzano@usc.edu> wrote in message <i9qe1b$mch$1@fred.mathworks.com>...<br>
> "Sheida " <s.d.not.this@gmail.com> wrote in message <i9q820$3h$1@fred.mathworks.com>...<br>
> > Hi I am trying to solve an equation (to eventually put in a loop). However, after I take care of the differentiating, I cannot replace the symbols with actual numbers. Could someone please help me? <br>
> > Here is what my m file looks like: <br>
> > syms u1 u2<br>
> > f = [(u1^3)  u2; (u2^3)  u1];<br>
> > u = [u1;u2];<br>
> > J = jacobian(f,u);<br>
> > Ji = inv(J);<br>
> > b = Ji*f;<br>
> > u1 = 2;<br>
> > u2 = 1;<br>
> > u = u  b<br>
> > <br>
> > my result for "u" is:<br>
> > u =<br>
> > <br>
> > u1 + (u1  u2^3)/(9*u1^2*u2^2  1) + (3*u2^2*(u2  u1^3))/(9*u1^2*u2^2  1)<br>
> > u2 + (u2  u1^3)/(9*u1^2*u2^2  1) + (3*u1^2*(u1  u2^3))/(9*u1^2*u2^2  1)<br>
> > <br>
> > I want matlab to replace all u1s with 2 and all u2s with 1. I have been searching for the past couple of hours and have not found anything. It doesn't seem like it is too hard but I just cant figure it out! <br>
> > Thanks! <br>
> <br>
> I dont have the symbolic toolbox but this might work. If you can convert "u" to a character array (im not sure if that is possible at all) then you can regexprep to replace the values you want, then evaluate it with eval also, hope that helps<br>
<br>
i believe that the 'char' function will convert a sym to a string

Thu, 21 Oct 2010 22:44:03 +0000
Re: Change symbols back to numbers
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/294499#789682
Roger Stafford
"Sheida " <s.d.not.this@gmail.com> wrote in message <i9q820$3h$1@fred.mathworks.com>...<br>
> .......<br>
> my result for "u" is:<br>
> u =<br>
> <br>
> u1 + (u1  u2^3)/(9*u1^2*u2^2  1) + (3*u2^2*(u2  u1^3))/(9*u1^2*u2^2  1)<br>
> u2 + (u2  u1^3)/(9*u1^2*u2^2  1) + (3*u1^2*(u1  u2^3))/(9*u1^2*u2^2  1)<br>
> <br>
> I want matlab to replace all u1s with 2 and all u2s with 1. I have been searching for the past couple of hours and have not found anything. It doesn't seem like it is too hard but I just cant figure it out! <br>
> Thanks! <br>
          <br>
Use 'subs'.<br>
<br>
Roger Stafford