Difference between revisions of "MATLAB1"

From SourceWiki
Jump to navigation Jump to search
Line 47: Line 47:
  
 
=Vectors and Matrices=
 
=Vectors and Matrices=
 +
 +
separated by either commas or spaces:
 +
 +
<source lang="matlab">
 +
v = [ 1 3, sqrt(5)]
 +
</source>
 +
 +
<pre>
 +
v =
 +
1.0000  3.0000  2.2361
 +
</pre>
 +
 +
<source lang="matlab">
 +
length(v)
 +
</source>
 +
 +
<pre>
 +
ans =
 +
3
 +
</pre>
 +
 +
 +
<source lang="matlab">
 +
v = [ 1; 3; sqrt(5)]
 +
</source>
 +
 +
<pre>
 +
c =
 +
    1.0000
 +
    3.0000
 +
    2.2361
 +
</pre>
  
 
=Plots=
 
=Plots=

Revision as of 16:03, 7 June 2013

An Introduction MATLAB

Introduction

http://www.mathworks.co.uk/moler/intro.pdf

Getting Started: Some Arithmetic

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

Fibonacci Numbers

Vectors and Matrices

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

Plots

Ready Reference

http://www.maths.dundee.ac.uk/ftp/na-reports/MatlabNotes.pdf