%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% solves the set of equations                   %
%                                               %
%   x' = by - c(x - xstar)                      %
%   y' = xz - y                                 %
%   z' = -xy - (z - 1)                          %
%                                               % 
% requires the use of file:  Vallisode.m        % 
% from Appendix B.2  K K Tung's book            % 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear;

global b;
global c;
global xstar;


  b = 102;
  c = 3;
  xstar = 0;
% time span of integration
  tspan = [0 60];
% initial conditions
x0 = 0;
y0 = 2.0/12.0;
z0 = 1.0;
v0 = [x0,y0,z0];  % IC's

% solves ode using ode45 routine

[t,vout] = ode45(@Vallisode,tspan,v0);

% 
%   plots y(t) for xstar=0.0 in an upper subplot
%

% note:
paramstring = sprintf( ', {\\itb}=%d, {\\itc}=%d,{\\itx_0}=%d', b, c, xstar);

figure(1)
clf
subplot(2,1,1)

plot( t, vout(:,2) );
xlabel( '{\itt}' );
ylabel( '{\ity}({\itt})' );
title( ['East-west Temperature Difference', paramstring ] )
axis tight;
grid on;
%%%%%%%%%%%%%%%%%%
xstar = -0.83;

[t,vout] = ode45(@Vallisode,tspan,v0);

% 
%   plots y(t) for specified xstar in an lower subplot
%

% note:
paramstring = sprintf( ', {\\itb}=%d, {\\itc}=%d,{\\itx_0}=%2.2f', b, c, xstar);
subplot(2,1,2)
plot( t, vout(:,2) );
xlabel( '{\itt}' );
ylabel( '{\ity}({\itt})' );
title( ['East-west Temperature Difference', paramstring ] )
axis tight;
grid on;
