function [t,W]=my_trig(int,w0,h)
% my_trig - solves initial value problem for the system of 
%          ordinary differential equations w'=Aw, A=[0 1;-1 0] 
%   Syntax: 
%           [t,W]=my_trig(int,w0,h)
%   Arguments: 
%           int - 1x2 matrix specifying a time interval int=[a,b]
%           w0  - 2x1 matrix specifying an initial value
%           h   - positive number, the stepsize
%   Returns: 
%           t - nx1 matrix containg the time points with t(1)=a
%           W - nx2 matrix containing the approximate solution
%   Description:
%           The program computes an approximate solution of the intial 
%           value problem  w'=Aw, a<t<b; w(a)=w0, A=[0 1;-1 0].  Here w
%           and w0 are column vectors of dimension 2x1.  
%           The program returns the nx1 matrix t of time points with 
%           t(1)=a and the nx2 matrix W with row number i containing 
%           the transposed solution vector at time t(i).  
%           The program uses the Euler forward method. 
%   Examples: 
%          [t,W]=my_trig([0,pi], [0;1], 1e-3);
%          computes half a period of sin(t)
%          plot(t,W)             plots the solution curves
%          plot(W(:,1),W(:,2))   plots the phase portrait
%           

%----------------------------------------------------------------------
%
%   Date created: 
%          
%   Author:
%          
%------------------------------+---------------------------------------+
Write your program here! 

This program is very similar to my_exp.m.  

The main difference is that W(i) is a 2x1 column vector and c is
replaced by the matrix A=[0 1;-1 0].

Hint: the following may be useful. 

W(:,i) denotes column i of the matrix W, it is a 2x1 column
compute these columns by the algorithm

W(:,i)=  W(:,i-1) + h* ??? ; 

Finally transpose W so that it becomes a (N+1)x2 matrix 

W=W'; 

What I mean is that: during the computation W has the form 

W= ::::::::::::       2x(N+1)

but in the output W=W' has the form 

W= ..      (N+1)x2
   .. 
   .. 
   .. 
   .. 
   .. 
   .. 
   .. 
   .. 
   .. 
   .. 
   .. 

where the dots indicate the elements of the matrix.  This is 
necessary for the plot commands to be simple. 

Transpose t also. 

/stig 

   
   






