I need your help. y'(t) = -30*y+30*t^2+2*t; y(0)=1, & exact solution is y(t)=e^-30*x +x^2. i can't understand what is different b/w kr4 plotting & its error . i need both graph n error please send me code.
이전 댓글 표시
function rungekutta123
h = 0.05;
t = 0;
w = 1;
fprintf('Step 0: t = %12.8f, w = %12.8f\n', t, w);
for i=1:50
k1 = h*f(t,w);
k2 = h*f(t+h/2, w+k1/2);
k3 = h*f(t+h/2, w+k2/2);
k4 = h*f(t+h, w+k3);
w = w + (k1+2*k2+2*k3+k4)/6;
t = t + h;
fprintf('Step %d: t = %6.4f, w = %18.15f\n', i, t, w);
end
%%%%%%%%%%%%%%%%%%
function v = f(t,y)
v = -30*y+30*t^2+2*t;
댓글 수: 2
jamila nizamani
2014년 2월 2일
Image Analyst
2014년 2월 2일
Please read this: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup and fix your formatting.
채택된 답변
추가 답변 (1개)
Nurcan
2024년 4월 22일
0 개 추천
y(t)=f(t, y(t)) y(t0)=y0 tE[t0, T] f(t,y)=-y/(2*t)+t^2 t0=1 T=2 y0=1
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!