MATLAB Answers

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

1 ビュー (過去 30 日間)
Guillaume SIBILLE 2020 年 9 月 17 日

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 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.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!