This question is closed. Reopen it to edit or answer.
Line 11 Error: Subscript indices must either be real positive integers or logicals.
2 views (last 30 days)
Hello! I am trying to code the attached image, but my code gets the error described in the question title. This is my code so far. Any help would be appreciated. Thank you!
data = webread("https://web.njit.edu/~goodman/Math222/matlab1A.html")
tFinal = 2;
N = 33;
t=linspace(0,tFinal,N+1); % type 'help linspace' to see how this works
y(1) = 1; % setting the initial condition
k1 = y(n)*(3-t(n)*y(n));
k2 = y(n+h*k1)*(3-t(n+1)*y(n+h*k1));
y(n+1) = y(n) + h/2 * (k1+k2);
xlabel('t'); ylabel('y'); title('Look, ma! I solved another ODE in MATLAB!');
fprintf('The new error is %f.\n', error200);