Filter löschen
Filter löschen

Extract Value from ODE45

3 Ansichten (letzte 30 Tage)
BINAY NAYAK
BINAY NAYAK am 16 Mär. 2022
Kommentiert: BINAY NAYAK am 17 Mär. 2022
I am Using below code to plot 2 graphs using ODE45. However I want to know a particular value of "t" at y(2) = 0.1
Is it possible?
%For plots
[t,y] = ode45(@odefun3,[0:0.1:50],[300; 2]);
plot(t,y(:,1))
plot(t,y(:,2))
function dydt = odefun3(t,y)
dydt = zeros(2,1);
dydt(1) = 125*0.01725*exp(-2660*(1/y(1)-1/300))*y(2)^2;
dydt(2) = -0.01725*exp(-2660*(1/y(1)-1/300))*y(2)^2;
end

Antworten (1)

Walter Roberson
Walter Roberson am 16 Mär. 2022
No, you can only interpolate the position, as there is no t value at which y(:,2) is exactly 0.1.
%For plots
[t,y] = ode45(@odefun3,[0:0.1:50],[300; 2]);
plot(t,y(:,1))
plot(t,y(:,2))
format long g
t01 = interp1(y(:,2), t, 0.1, 'spline')
t01 =
19.8851354380905
function dydt = odefun3(t,y)
dydt = zeros(2,1);
dydt(1) = 125*0.01725*exp(-2660*(1/y(1)-1/300))*y(2)^2;
dydt(2) = -0.01725*exp(-2660*(1/y(1)-1/300))*y(2)^2;
end

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by