Substituting a function from a differential equation

8 ビュー (過去 30 日間)
Sean Thrasher
Sean Thrasher 2020 年 7 月 30 日
回答済み: Surya Talluri 2020 年 8 月 7 日
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.
  1 件のコメント
Sean Thrasher
Sean Thrasher 2020 年 7 月 30 日
I am using MATLAB_R2020a

サインインしてコメントする。

回答 (1 件)

Surya Talluri
Surya Talluri 2020 年 8 月 7 日
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:

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by