% Declare the relevant parameters
h=0.1
w0=1000
g=0.2
tmax=10

nmax=tmax/h;

wlast=w0;

% Beginning of Euler Integration

for i=1:nmax
  x(i)=i*h;
  w(i)=wlast*(1+h*g);
  y(i)=w0*exp(g*x(i));
  d(i)=abs(y(i)-w(i));
  wlast=w(i);
end 

% Plot Results for w, y

plot(x,w,'ob');
xlabel('Time (Years)');
ylabel('Population N');
hold on;
plot(x,y,'r');

% Save the results (for each timestep) in a file

file = zeros(size(x,2),4);

file(:,1)=x';
file(:,2)=w';
file(:,3)=y';
file(:,4)=d';

save output.pop file -ASCII;
