This code for an ODE function with boundary condition, and it can only given an answer at selected time,in this coding is at t=1 t. I need to add in a loop with a small time increment, from t=0 to t=20 at increment of t=0.01. Can anyone please help me ? I need to solve this problem.
solinit = bvpinit(linspace(0,1,10),[0,0,]);
sol = bvp4c(@ex1ode,@ex1bc,solinit);
y = linspace(0,1);
u = deval(sol, y);
plot(u(1,:),y)
title ('beta = 1');
xlabel ('u*');
ylabel ('y*');
legend ('t=1');
function dudy = ex1ode(y,u)
t=1;n=1;U = 1; pho = 1; eta = 1;
uini = 0;
dudy = [ u(2)^(1/n)
(pho/eta) *((u(1)-0)/ t)];
end
function res = ex1bc (ua,ub)
t=1;U=1; omega = 1;
res=[ua(1)- U*sin(omega*t)
ub(1)];
end

 채택된 답변

Torsten
Torsten 2018년 5월 16일

0 개 추천

t=0.01:0.01:20;
for i=1:numel(t)
solinit = bvpinit(linspace(0,1,10),[0,0]);
sol{i} = bvp4c(@(y,u)ex1ode(y,u,t(i)),@(ua,ub)ex1bc(ua,ub,t(i)),solinit);
end
function dudy = ex1ode(y,u,t)
n=1;U = 1; pho = 1; eta = 1;
uini = 0;
dudy = [ u(2)^(1/n)
(pho/eta) *((u(1)-0)/ t)];
end
function res = ex1bc (ua,ub,t)
U=1; omega = 1;
res=[ua(1)- U*sin(omega*t)
ub(1)];
end
Best wishes
Torsten.

댓글 수: 1

Chee Hao Hor
Chee Hao Hor 2018년 5월 16일
I had found my problem, thanks anyway. btw, your code seem like not able to run.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2018년 5월 16일

댓글:

2018년 5월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by