MATLAB: Attempted to access t(10); index out of bounds because numel(t)=1.

differential equations

Im trying to solve 2 differential equation with 4th order Runge Kutta method but i can't solve problem that
Error in motor (line 22)
t(i+1)=t(i)+h;
R=1.57;
Le=3.59;
Km=90.42*10^-3;
fe=273*10^-6;
j=545*10^-6;
Ue=24;
clear;clc
% define functions
fa=@(t,a,w) 1/Le*(Ue-Re*a-Km*w);
fw=@(t,a,w) 1/j*(Km*a-fe*w);
%initial conditions
t(1)=1;
a(1)=0;
w(1)=0;
%step size
h=0.1;
tfinal=1;
N=ceil(tfinal/h);
%update loop
for i=N
%update time
t(i+1)=t(i)+h;
%Update a w
k1a=fa(t(i),a(i),w(i));
k1w=fw(t(i),a(i),w(i));
k2a=fa(t(i)+h/2,a(i)+h/2*k1a,w(i)+h/2*k1w);
k2w=fw(t(i)+h/2,a(i)+h/2*k1a,w(i)+h/2*k1w);
k3a=fa(t(i)+h/2,a(i)+h/2*k2a,w(i)+h/2*k2w);
k3w=fw(t(i)+h/2,a(i)+h/2*k2a,w(i)+h/2*k2w);
k4a=fa(t(i)+h,a(i)+h*k3a,w(i)+h *k3w);
k4w=fw(t(i)+h,a(i)+h*k3a,w(i)+h *k3w);
a(i+1)=a(i)+h/6*(k1a+2*k2a+2*k3a+k4a);
w(i+1)=w(i)+h/6*(k1w+2*k2w+2*k3w+k4w);
end

Best Answer

for i = 1 : N