How can I define this differential equation in matlab syntax to solve it using ode45 ?
4 views (last 30 days)
Show older comments

I want to solve this equation for tau,
gammadot is not a differential term
the values for lamda1, lambda2, eta0, gamma are known
edit: I just want to know how to write this equation in a way that matlab understands
2 Comments
Torsten
on 5 Dec 2023
Was there something unclear about the responses you already received for this question ?
Accepted Answer
Sam Chak
on 6 Dec 2023
Hi @Namit Dayal
Depending on the values of
, this is one way to solve the differential equations using the 'ode45()' solver. Here, I assume that
grows linearly with time, as illustrated in the third subplot.
tspan = [0 1000];
y0 = [1 0 0];
[t, y] = ode45(@odefcn, tspan, y0);
subplot(311)
plot(t, y(:,1)), grid on, ylabel \tau
subplot(312)
plot(t, y(:,2)), grid on, ylabel \gamma
subplot(313)
plot(t, y(:,3)), grid on, ylabel \gamma\prime, xlabel t
%% Differential equations
function dydt = odefcn(t, y)
dydt = zeros(3, 1);
eta0 = 8080;
lambda1 = 1.109;
lambda2 = lambda1;
dydt(1) = - (y(1) + eta0*y(3) + eta0*lambda2*1)/lambda1;
dydt(2) = t; % gammadot = t (grows linearly from 0 to 1000 in 1000 s)
dydt(3) = 1; % d gammadot/dt = 1 (differentiate t with respect to t)
end
0 Comments
More Answers (1)
Sam Chak
on 5 Dec 2023
Hmm... @Namit Dayal, but you declared that "gammadot is not a differential term". Thus, only
is regarded as the differential term. Also, the values for the rest of the parameters
,
,
, and
are known. If these values are constants such that
, then
, and the differential equation can be reduced to
.
, and the differential equation can be reduced to The analytical solution for this first-order ODE is given by

where
is the initial value.
I hope you have disclosed all information regarding this math problem. If my assumption about
is incorrect, then the solution becomes illegitimate.
4 Comments
Torsten
on 5 Dec 2023
I have a doubt, suppose gamma is a set of values from 0.001 to 1000, then will d(gamma)/dt be equal to zero as well ?
In your preceding question that can be found here
I asked
Do you want to compute one function for tau and treat gamma(dot) is a function of t
or
do you want to compute as many functions tau as there are parameters for gamma(dot) and treat gamma(dot) as constant for each of these computations ?
and you answered
I want to treat gamma(dot) as a vector of constants and solve for tau for all values of gamma(dot) separately
Assuming the same is true here, @Sam Chak gave you the solution of the differential equation with gammadot = constant and thus d(gammadot)/dt = 0 (although I doubt this is meant in the differential equation).
See Also
Categories
Find more on Matrix Computations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
