Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: assignment to variable in symbolic expression
Replies: 2   Last Post: Aug 24, 2011 12:52 PM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Martin Posts: 43 Registered: 4/7/10
Re: assignment to variable in symbolic expression
Posted: Aug 24, 2011 12:52 PM
 Plain Text Reply

Alan Weiss <aweiss@mathworks.com> wrote in message <j3371m\$o36\$1@newscl01ah.mathworks.com>...
> On 8/24/2011 11:16 AM, Martin wrote:
> > Hi,
> > I just started using symbolic toolbox, hope my question is not too basic...
> > I've done some calculations in Mupad:
> >
> > ---Mupad----------------------------------------------------------------------
> >
> > eq1 := solve(ode(v''(z) = -1/15*z*(1-1/(2*a)-z/2), v(z)))
> > -> C3 + C2*z + z^4/360 - (z^3*(2*a - 1))/(180*a)
> > C3 := 0
> > solve(eq1,C2)
> > ----------------------------------------------------------------------------------
> >
> > Now I want to do the same in MATLAB (because this is the only sybolic
> > calculation that has to be done)
> > ---MATLAB----------------------------------------------------------------

> >>> eq1 = dsolve('D2y = -1/15*z*(1-1/(2*a)-z/2)','z')
> > eq1 =
> > z^4/360 + (1/(180*a) - 1/90)*z^3 + C5*z + C6
> > ?
> > ---------------------------------------------------------------------------
> > so how do I assign a value to C6 and solve the equation?
> >
> > thanks in advance, martin

>
> eq2 = subs(eq1,{'a','C2','C3'},{-1,2,4})
>
> eq2 =
>
> z^4/360 - z^3/60 + 2*z + 4
>
> You could also use matlabFunction if you want something that runs faster:
> tt = matlabFunction(eq1,'Vars',{'z','a','C2','C3'})
>
> tt =
>
>
> @(z,a,C2,C3)C3+C2.*z+z.^3.*((1.0./1.8e2)./a-1.0./9.0e1)+z.^4.*(1.0./3.6e2)
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

thank you! :-)

Date Subject Author
8/24/11 Martin
8/24/11 Alan Weiss
8/24/11 Martin

© The Math Forum at NCTM 1994-2017. All Rights Reserved.