Substituting a function from a differential equation

8 vues (au cours des 30 derniers jours)
Sean Thrasher
Sean Thrasher le 30 Juil 2020
Hi, I am a beginner and I am learning symbolic math toolbox for MATLAB.
I have got a system of differential equations
and a definition for alpha:
where r = √(x^2 +y^2 +z^2).
My aim is to differentiate alpha with respect to t, and then substitute the differential equations to obtain
My code looks like this:
syms alpha(t) beta(t) r(t) x(t) y(t) z(t) t epsilon theta(t)
r(t) = sqrt((x(t))^2+(y(t))^2+(z(t))^2)
dtheta(t)=diff(theta(t),t)
alpha(t) = sqrt(( r+z(t))/(2*r))
beta(t) = (x(t)+ i*y(t))/sqrt(2*r*(r+z(t))) %I want to do the same for beta too, differentiate it w.r.t t and substitute the differential equations
diffeqn1 = epsilon*diff(x(t),t) == -y(t) - epsilon*dtheta(t)*z(t)
diffeqn2 = epsilon*diff(y(t),t) == x(t)
diffeqn3 = diff(z(t),t) == dtheta(t) * x(t)
diff(alpha(t),t)
But of course, I only get an expression involving the derivatives of x(t),y(t),z(t).
How can I make the program take diffeqn1 ,diffeqn2, diffeqn3 into consideration?
Any help would be massively appreciated.

Réponses (1)

Surya Talluri
Surya Talluri le 7 Août 2020
I understand that you want to substitute diff(x(t),t), diff(x(t),t), diff(x(t),t) values in diff(alpha(t),t). You can use “isolate” function to obtain differentiation equations and substitute them in diff(alpha(t),t).
dx = diff(x(t),t);
dy = diff(y(t),t);
dz = diff(z(t),t);
diffeqn1 = epsilon*dx == -y(t) - epsilon*dtheta(t)*z(t);
diffeqn2 = epsilon*dy == x(t);
diffeqn3 = dz == dtheta(t) * x(t);
diffeqn1 = isolate(diffeqn1, dx);
diffeqn2 = isolate(diffeqn2, dy);
diffeqn3 = isolate(diffeqn3, dz);
dalpha = diff(alpha(t),t);
dalpha = subs(dalpha, {lhs(diffeqn1), lhs(diffeqn2), lhs(diffeqn3)}, {rhs(diffeqn1), rhs(diffeqn2), rhs(diffeqn3)});
You can refer to the following documentation for further understanding:

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by