Difference between revisions of "MATLAB1"

From SourceWiki
Jump to navigation Jump to search
Line 4: Line 4:
 
=Introduction=
 
=Introduction=
  
http://www.mathworks.co.uk/moler/intro.pdf
+
Rather than re-invent the wheel, we'll use some tried and tested tutorial material.  The following notes from the Maths department at the University of Dundee are concise, comprehensive, but also easy to read:
 +
http://www.maths.dundee.ac.uk/ftp/na-reports/MatlabNotes.pdf
 +
 
 +
We'll follow those notes, but will add in some more detail of our own in various sections.  The section numbers and titles below will mirror those in the Dundee notes.
  
=Getting Started: Some Arithmetic=
+
=3 Matlab as a Calculator=
  
 
==The Golden Ratio==
 
==The Golden Ratio==
Line 44: Line 47:
 
</pre>
 
</pre>
  
==Fibonacci Numbers==
+
=8 Vectors=
 
 
=Vectors and Matrices=
 
  
 
separated by either commas or spaces:
 
separated by either commas or spaces:
Line 67: Line 68:
 
3
 
3
 
</pre>
 
</pre>
 
  
 
<source lang="matlab">
 
<source lang="matlab">
Line 79: Line 79:
 
     2.2361
 
     2.2361
 
</pre>
 
</pre>
 
=Plots=
 
 
=Ready Reference=
 
 
http://www.maths.dundee.ac.uk/ftp/na-reports/MatlabNotes.pdf
 

Revision as of 10:56, 27 June 2013

An Introduction MATLAB

Introduction

Rather than re-invent the wheel, we'll use some tried and tested tutorial material. The following notes from the Maths department at the University of Dundee are concise, comprehensive, but also easy to read: http://www.maths.dundee.ac.uk/ftp/na-reports/MatlabNotes.pdf

We'll follow those notes, but will add in some more detail of our own in various sections. The section numbers and titles below will mirror those in the Dundee notes.

3 Matlab as a Calculator

The Golden Ratio

http://en.wikipedia.org/wiki/Golden_ratio

phi = (1 + sqrt(5))/2
phi =
    1.6180
format long
phi
phi =
    1.618033988749895

φ2 − φ − 1 = 0

p = [1 -1 -1]
r = roots(p)
r =
  -0.618033988749895
   1.618033988749895

8 Vectors

separated by either commas or spaces:

v = [ 1 3, sqrt(5)]
v =
1.0000   3.0000   2.2361
length(v)
ans =
3
v = [ 1; 3; sqrt(5)]
c =
    1.0000
    3.0000
    2.2361