How to solve this
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
2 commentaires
Réponse acceptée
Ameer Hamza
le 30 Oct 2020
Modifié(e) : Ameer Hamza
le 30 Oct 2020
Following shows how to find a numerical solution. You ODEs seems stiff, therefore, I used a stiff solver (ode23s).
tspan = [0 10];
IC = [0; 0; 0];
[t, y] = ode23s(@odeFun, tspan, IC);
plot(t, y);
legend({'$\theta$', '$\dot{\theta}$', '$i(t)$'}, ...
'FontSize', 16, 'Interpreter', 'latex', 'Location', 'best')
function dXdt = odeFun(t, X)
J = 1;
Kt = 0.1;
b = 0.5;
L = 1e-2;
R = 10;
V = 1;
Ke = 0.5;
% X is 3x1 vector
% X(1) is theta, X(2) is theta_dot, X(3) = I
theta = X(1);
theta_dot = X(2);
i = X(3);
dXdt = zeros(3,1);
dXdt(1) = X(2);
dXdt(2) = 1/J*(Kt*i-b*theta_dot);
dXdt(3) = 1/L*(-R*i+V-Ke*theta_dot);
end
6 commentaires
Ameer Hamza
le 30 Oct 2020
In that case create a new file named odeFun.m in current MATLAB folder and paste the following code in it
function dXdt = odeFun(t, X)
J = 1;
Kt = 0.1;
b = 0.5;
L = 1e-2;
R = 10;
V = 1;
Ke = 0.5;
% X is 3x1 vector
% X(1) is theta, X(2) is theta_dot, X(3) = I
theta = X(1);
theta_dot = X(2);
i = X(3);
dXdt = zeros(3,1);
dXdt(1) = X(2);
dXdt(2) = 1/J*(Kt*i-b*theta_dot);
dXdt(3) = 1/L*(-R*i+V-Ke*theta_dot);
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations 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!