Effacer les filtres
Effacer les filtres

How can I define this differential equation in matlab syntax to solve it using ode45 ?

2 vues (au cours des 30 derniers jours)
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 commentaires
Torsten
Torsten le 5 Déc 2023
Was there something unclear about the responses you already received for this question ?
Namit Dayal
Namit Dayal le 5 Déc 2023
Hi Torsten , I apologize, I didnt frame my question correctly, For this equation i just want to understand how to define this equation as there are two differential terms in here and the syntax I've seen is for one term or 2nd order equations with the same differential.

Connectez-vous pour commenter.

Réponse acceptée

Sam Chak
Sam Chak le 6 Déc 2023
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

Plus de réponses (1)

Sam Chak
Sam Chak le 5 Déc 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 .
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 commentaires
Torsten
Torsten le 5 Déc 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).
Sam Chak
Sam Chak le 6 Déc 2023
Modifié(e) : Sam Chak le 6 Déc 2023
Perhaps the OP didn't know how to express the problem to us. 'gammadot' () is indeed a differential term, but it appears as a time-dependent term in data form. If that's the case, then the interpolation method using interp1() can be applied.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by