plotting Y1(2t) to get the correct figure instead of Y1(t)

조회 수: 3 (최근 30일)
Guillaume SIBILLE
Guillaume SIBILLE 2020년 9월 17일
답변: Ayush Gupta 2020년 10월 9일
I've been trying to solve the following system of differentiel equations and to plot one of these functions.
The solver works correctly but I have an unusual problem.
I get the correct graph when I plot y1(2*t) (like I did on this code) instead of y1(t), and I don't know why this is the case. I'm pretty sure that the other functions I made (u, ha and h) are correctly set up.
If anyone has a clue, I'd be glad to hear it!
Thanks in advance
%parameter
We = 780
Re = 1145
t_e = 1.05*We^(-2/3)
s_e = sqrt(3*t_e)
v_e = 0.5* sqrt(3/t_e)
b_e = ((sqrt(12)*t_e^1.5)/pi)
%time interval and initial conditions
t_interval = linspace(t_e,10,1000) ;
init_cond = [s_e b_e v_e];
%solution
[t,y] = ode113(@(t,y) odefcn(t,y, We) , t_interval , init_cond);
%plots y1(2t)
plot(t(1:1:end/2),y(2:2:end,1),'b');
loglog(t(1:1:end/2),y(2:2:end,1),'b')
axis([0.1 10 0.5 5])
function dydt = odefcn(t,y, We)
dydt = [ y(3);
((u(y(1),t)-y(3))*(h(y(1),t)))*4/(y(2)*pi);
(((u(y(1),t)-y(3))^2)*h(y(1),t)-2/We)*8/(y(2)^2*pi);];
end

답변 (1개)

Ayush Gupta
Ayush Gupta 2020년 10월 9일
The code works fine and there is no problem in it. One possible reason for this could be that these equations or functions are being mis-matched or wrong somewhere which is because of the context of the problem might not be understood fully.

카테고리

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