1: Array construction

x = [0,1,2];

x = 0:0.1:1;

x = linspace(0,1,11);

2: plot a function, 
 x = linspace(0,1,11);
  y = sin(x);
  plot(x,y);

3: Save all the commands in a file (file.m);
   type 'file' in the command window;
   
   The file should be in the same directory as the command window.
 
4: define a new 'function';
   function 'output' = myfunction('input');
   'output' = a function of 'input';
   
Example: function f = func1(x);
         f = x.^2-cos(x);
  
        Save these two lines in a file, named 'func1.m'.

        In the command window, x = 0:0.1:1;
                               y = func1(x);
                               plot(x,y);
 
5: Matrix
   
   A = [0,1,2;2,5,3];
   B = [0:1:10; 2:1:12];
   A.^2;
   A.^3;
   A.^(-2);
   
Go to: http://math.ucsd.edu/~driver/21d-s99/matlab-primer.html  for a quick start.


