MATLAB: How to solve this

dsolve

Best Answer

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
Related Question