# How to solve this

3 views (last 30 days)
Minh Danl on 30 Oct 2020
Commented: Ameer Hamza on 30 Oct 2020

KSSV on 30 Oct 2020
Substitute second equation into first and use ode45.
Minh Danl on 30 Oct 2020
Can i use dsolve for this math

Ameer Hamza on 30 Oct 2020
Edited: Ameer Hamza on 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

Ameer Hamza on 30 Oct 2020
How are you running the code? Have you used the odeFun() I have given in my answer? Which MATLAB release are you using?
Minh Danl on 30 Oct 2020
i'm using matlab 2014a
Ameer Hamza on 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