Substituing symbolic variable with the element of a matrix before using ode solver
Show older comments
So, I have this explicit ODE system (named Y):
Y =
(0.5*(1.95e290*cos(sin(3.0*t))^2*cos(sin(t))*sin(3.0*t) + [...] + 3... Output truncated. Text exceeds maximum line length of 25 000 characters for Command Window display.
-(0.5*(8.58e290*cos(sin(3.0*t))^2*sin(sin(t))*sin(3.0*t) + [...] + 4.16e253*cos(sin(3.0*t))*sin(sin(3.0*t))^4*cos(sin(t))^2*sin(sin(t))... Output truncated. Text exceeds maximum line length of 25 000 characters for Command Window display.
-(0.5*(2.13e295*cos(sin(3.0*t))^2*cos(sin(t))^2*sin(t) + [...] +3.98e260*cos(sin(3.0*t))^2*sin(sin(3.0*t))^3*cos(sin(t))*sin(sin(t))^4*sin(30.0*t)^3*sin(t) + 4.16e2 ... Output truncated. Text exceeds maximum line length of 25 000 characters for Command Window display.
in which each equation of the equations systems depends of 4 variables, which are the time "t", "theta1p(t)", "theta2p(t)" and "theta3p(t)". Now, as you can see, the equations of this system are kinda long and I need to find a way to substitute the thetaXp by a y(X) so I can use this system of equation with the ODE solver function ode45. That means that in Y above, I need to substitute:
theta1p with y(1)
theta2p with y(2)
theta3p with y(3)
So that I may be able to do:
tspan=[0 10]
initcond=[0 ; 0 ; 0]
[t,y45]=ode45(Y,tspan,initcond)
I already tried doing substitutions such as
[t,y45]=ode45(@(t,y) (subs(Y,[theta1p ; theta2p ; theta3p],[y(1) ; y(2) ; y(3)])),tspan,initcond)
but it doesn't seem to work. If it's of any help, I've joined my code to this post and I identified the section where I'm stuck by a series of "HERE" that are hard to miss (it's near the end of the code)
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!