I have used successfully used ode45 on several occasions. Now I am trying to "improve" my utilization. Previously I had something like ---
for i = 1 : dx
[t,y] = ode45( 'ffssl' , [0,xinit(i)], yinit ) ;
fprintf ( fp , ' %f\t%f\n' , xinit(i) , y(end) ) ;
end ;
I would like to use something such as the following ---
for i = 1 : dx
[t,y] = ode45 ( 'ffssl' , [xinit(i),xinit(i+1)], <yinit> ) ;
fprintf ( fp , ' %f\t%f\n' , xinit(i+1) , <y(end)> ) ;
end ;
Is this even possible? If so, I do not know how do provide the proper y initial value yinit or the y calculated value y(end). Any suggestions would be appreciated. Thanks very much in advance.

댓글 수: 1

Matt Tearle
Matt Tearle 2011년 5월 9일
Can you explain what you're trying to achieve? It looks like you're writing out the solution at some given times (x values). But you wouldn't need a loop for that.

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

답변 (1개)

Walter Roberson
Walter Roberson 2011년 5월 9일

0 개 추천

At first glance it appears you could use
xi = [0, xinit];
for i = 1 : length(xi)-1
[t,y] = ode45 ( 'ffssl', [xi(i),xi(i+1)], yinit(i) ) ;
fprintf( fp, ' %f\t%f\n', xi(i+1), y(end) );
end
but I have no idea what your proper yinit values should be if they are not to be constant.

카테고리

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

제품

태그

질문:

2011년 5월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by