% 1) Find the solution to the discrete model % X_{t+1} = X_t +4Y_t % Y_{t+1} = .5 X_t % if X_0 = 6 and Y_0 = 0 % Plot time series of the solution, and plot the solution in a phase plane. % If you use 35 timesteps the numbers will be enormous; try it with timesteps=8.
My attempt at the matlab code >> clear all; >> timesteps=8; >> x=[6; 0]; xhistory=x; >> A=[1 4; 0.5 0]; >> for t=1:timesteps; x=A*x; xhistory=[xhistory x]; end >> time=0:timesteps; >> subplot(2,1,1) >> plot(time,xhistory(1,:),'-'), xlabel('time'), ylabel('populations'), hold on >> plot(time, xhistory(2,:)) >> subplot(2,1,2) >> plot(xhistory(1,:), xhistory(2,:)), xlabel('juveniles'), ylabel('adults'), hold on >> [V,D]=eig(A) V = 0.9701 -0.8944 0.2425 0.4472 D = 2 0 0 -1 >> C= V\xhistory(:,1) C = 4.1231 -2.2361 >> xpprox = C(2)*V(:,2)*D(2,2).^(time) xpprox = Columns 1 through 3 2.0000 -2.0000 2.0000 -1.0000 1.0000 -1.0000 Columns 4 through 6 -2.0000 2.0000 -2.0000 1.0000 -1.0000 1.0000 Columns 7 through 9 2.0000 -2.0000 2.0000 -1.0000 1.0000 -1.0000 >> subplot(2,1,1) >> plot(time,xpprox,'r') >> subplot(2,1,2) >> plot(xpprox(1,:),xpprox(2,:),'r')
>> x=[6; 0]; xhistory=x; initial conditions >> A=[1 4; 0.5 0]; projection matrix.
just wondering if it's correct @dan815 I already computed this problem by hand and I got lambda -1 and 2 and when I found my c1 and c2 values it was c1=-1 and c2=1 but the main focus is the graph for the Juveniles and Adults population with timesteps and phase planes.
is X=adults?
is x adults? is the labeling off?
|dw:1425615349064:dw|
Join our real-time social learning platform and learn together with your friends!