naxmall.blogg.se

Matlab symbolic toolbox eval
Matlab symbolic toolbox eval




Do f(1) = 1 and f(2) = n really hold? checkInitCond1 = subs(f,t,1) Result = simplify(t^2*diff(f,2)+t*diff(f)+(t^2-n^2)*f)įinally, we should also check the initial values. But because the string input does not let us use subs to directly plug the solution into the ODE, we, again, have to do some manual work: syms t In order to verify that the solution is correct, we need to plug it into the ODE and see if this gives 0. (bessely(1, 1) - bessely(1, 2)) besselj(1, t)Īnother limitation becomes obvious when we try to check the solution.

matlab symbolic toolbox eval matlab symbolic toolbox eval

We more or less have to modify the ODE by hand replacing all appearances of n by 1: f = dsolve( 't^2*D2y+t*Dy+(t^2-1^2)*y', 'y(1)=1', 'y(2)=1', 't') Just defining n = 1Īnd re-evaluating the command f = dsolve(besselODE, 'y(1)=1', 'y(2)=n', 't') ĭoes not work, since the value for n shows up in the string defining the differential equation: besselODE Say you want to assign a special value to n, e.g., n = 1, and solve the equation again using this new value for n. Such string-based input for the dsolve function has some limitations. (n bessely(n, 1) - bessely(n, 2)) besselj(n, t) (n besselj(n, 1) - besselj(n, 2)) bessely(n, t)īesselj(n, 1) bessely(n, 2) - besselj(n, 2) bessely(n, 1) Here is a typical example that shows how you can solve a Bessel ODE with two given initial values: besselODE = 't^2*D2y+t*Dy+(t^2-n^2)*y' į = dsolve(besselODE, 'y(1)=1', 'y(2)=n', 't') The usual way to solve ordinary differential equations (ODEs) using the Symbolic Math Toolbox dsolve command is to set up the equations using string syntax. Solving Ordinary Differential Equations Using String Input

matlab symbolic toolbox eval

Then we compute the same results again using symbolic equations and symbolic functions and discuss how this improves our workflow.First, we solve the differential equation using string syntax and point out some limitations of string syntax.






Matlab symbolic toolbox eval