필터 지우기
필터 지우기

Extract Value from ODE45

조회 수: 3 (최근 30일)
BINAY NAYAK
BINAY NAYAK 2022년 3월 16일
댓글: BINAY NAYAK 2022년 3월 17일
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

답변 (1개)

Walter Roberson
Walter Roberson 2022년 3월 16일
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

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by