
1: 'Matrix caculation:'

A = rand(2);
inv(A);
A';

'Solve Ax = b;'

b = [0;1];
x = inv(A)*b;
'or',
x = A\b;

'Special functions to build a matrix'
rand(3);
rand(3,4);
eye(4);
ones(4);
ones(4,5);

2: if expression1 
     statement1
   elseif expression2
     statement2
   else
     statement3
   end

  x = 2;
  if (x > 2)
    display('x is bigger than 2');
  elseif (x == 2)
    display('x is equal to 2');
  else
    display('x is less than 2');
  end

3: "Some commands"

who
mkdir math105LA
what
pwd
clear all
close all

4: "Save a matlab file (.m) and created functions in the same 
     directory as the command window"

"pracise1_1.m":
   
   clear all;
   close all;
   x = linspace(0.2,1.3,100);
   y = func1_1(x);
   plot(x,y)
   line([0.2,1.3],[0,0])
   zero1 = fzero(@func1_1,0.2);
   zero2 = fzero(@func1_1,1.3);

"func1_1.m":
  function f = func1_1(x)
  f = x.*cos(x)-2.0*x.^2+3*x-1;   

5: "See how the function works"

  help line;
  help fzero; 
  
6: "loops"

  for variable = array
   statements
  end

  clear all;
  close all;
  for i = 1:10
    x(i) = i;
  end
  
  who
  x

7: "Debug"

In the matlab file (.m), click the left on the line that you want to set a 
breakpoint, and run the file. The program will stop right at this line.
Click 'Debug' in the edit window, go to 'step' to let the program run till
the next breakpoint.


Remarks:

Please come to my office for all kinds of questions. Do not be afraid.
You do not need to worry about it even if you never did the programming before.
The programming's experience is not required for this course. 
We will work together to make you a professional programmer!

Sometimes there are stupid answers, there are no stupid questions! 
Enjoy the programming!
   

