How do we plot differential Equation

4 ビュー (過去 30 日間)
Jun Young Choi
Jun Young Choi 2020 年 11 月 4 日
編集済み: Ameer Hamza 2020 年 11 月 4 日
With theta1(0)=0.1, theta2(0)=0.3, theta3(0)=0.2 , I have to plot the solution in the range of [0.1] all in one graph.
I have no idea how to do this:
diff(theta1)=1+sin(theta2-theta1);
diff(theta2)=1+sin(theta1-theta2)+sin(theta3-theta2);
diff(theta3)=1+sin(theta2-theta3);
ezplot(
Please help

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 4 日
編集済み: Ameer Hamza 2020 年 11 月 4 日
Use ode45() for estimating a numerical solution
IC = [0.1, 0.3, 0.2];
tspan = [0 1];
[t, thetas] = ode45(@odeFun, tspan, IC);
plot(t, thetas);
legend({'\theta_1', '\theta_2', '\theta_3'}, 'FontSize', 16, 'Location', 'best');
function dthetas = odeFun(t, thetas)
theta1 = thetas(1);
theta2 = thetas(2);
theta3 = thetas(3);
dtheta1 = 1+sin(theta2-theta1);
dtheta2 = 1+sin(theta1-theta2)+sin(theta3-theta2);
dtheta3 = 1+sin(theta2-theta3);
dthetas = [dtheta1; dtheta2; dtheta3];
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by