% EPS 131: Intro to physical Oceanography 
% HW-02: challenge problem
% Laure Zanna
clear all; close all;

n=10;m=10;
[X,Y] = meshgrid(0:10,0:10);

t=10; U_0=1.1; V_0=0.1; k=1; c=1;
%velocity
u=U_0+0*X; v=V_0*cos(k*(X-c*t) );
%find streamlines from matlab function streamslice
figure(1); streamslice(X,Y,u,v);
xlabel('x_1','fontsize',13); ylabel('x_2','fontsize',13); 
title('Streamlines for U_0-c<<U_0','fontsize',14)

%trajectories
X_2=2; X_1=1;
t=0:0.01:100;
traj_1=U_0*t+X_1;
traj_2=X_2+(V_0/(k*(U_0-c)) )  * ( sin(k*(X_1+ (U_0-c)*t) )  -sin(k*X_1 ));
figure; plot(t,traj_1,t,traj_2); title('Trajectory','fontsize',14); 
xlabel('Time','fontsize',13); ylabel('x_1,x_2','fontsize',13); 
legend('x_1','x_2')
figure; plot(traj_1,traj_2); title('Trajectory in the x_1-x_2 plane','fontsize',14); 
xlabel('x_1','fontsize',13); ylabel('x_2','fontsize',13);
