Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Martin

Posts: 42
Registered: 4/7/10
Re: assignment to variable in symbolic expression
Posted: Aug 24, 2011 12:52 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic 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! :-)



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.