RungeKuttaMethod matlab general function problem this what I have for the genera
ID: 3011838 • Letter: R
Question
RungeKuttaMethod matlab general function problem
this what I have for the general function please fill the missing part wich indicate as ....
function [xvals yvals]=RungeKuttaMethod(xmin,xmax,steps,y0)
% calculate the step size;
h=(xmax-xmin)/steps;
% now set up a list of x values
% need the list to have steps+1 numbers in it
% because the initial x is counted as 1
xvals=linspace(xmin,xmax,steps+1);
x=xmin;
% initialize y and yvals
y=y0; yvals=[y];
% now a for loop to build the yvals
for i=1:steps
...
y=...
% add y to the list of yvals
yvals=[yvals y];
% update x
x=xvals(i+1);
end
end
Explanation / Answer
In the blank space these statements will come: k1 = h(-2x(i)-y(i)); k2 = h(-2(x(i)+0.5h)-(y(i)+0.5k1)); k3 = h(-2(x(i)+0.5h)-(y(i)+0.5k2)); k4 = h(-2(x(i)+h)-(y(i)+k3)); y(i+1) = y(i)+(k1+k2+k3+k4)/6; x(i+1) = x(i)+h;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.