Substituting a function from a differential equation
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
Antworten (1)
Surya Talluri
am 7 Aug. 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:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!