Introduction to Matlab

10
Introduction to Matlab T.E. Ochsner 2011

description

Introduction to Matlab. T.E. Ochsner 2011. Getting Started with Matlab. http://www.mathworks.com/videos/matlab/getting-started-with-matlab.html. OSU Matlab Site License. E-mail Gary Hoefar in the IT Dep. [email protected] Request access to download and activate Matlab . - PowerPoint PPT Presentation

Transcript of Introduction to Matlab

Page 1: Introduction to  Matlab

Introduction to Matlab

T.E. Ochsner2011

Page 2: Introduction to  Matlab

Getting Started with Matlab

• http://www.mathworks.com/videos/matlab/getting-started-with-matlab.html

Page 3: Introduction to  Matlab

OSU Matlab Site License

• E-mail Gary Hoefar in the IT Dep. [email protected]

• Request access to download and activate Matlab.• After you get Gary’s response, go to

http://www.mathworks.com/• Create an account using the same name and e-mail

you gave Gary.• Download, install, and activate the appropriate

version for your operating system– Current release is R2011a

Page 4: Introduction to  Matlab

Weak traceability

Record data in field or lab book

Enter data in Excel

Perform some calculations

Enter some parameters in Excel

Copy and paste the tranformed data into a convenient

format for SAS

Import the transformed data to

SAS and do some more calculations

Enter the SAS output into a table

in your thesis

Import the transformed data

into SigmaPlot

Create some figures in SigmaPlot

Copy and paste the SigmaPlot figures in

your thesis

Page 5: Introduction to  Matlab

Improved traceability

Record data in field or lab book

Create raw data file in .csv, .xlsx, or other format

Create Matlab script to process

the data, generate figs, and run stats.

Copy and paste the Matlab figures and

stats into your thesis.

Page 6: Introduction to  Matlab

Weak graphics

1 1.5 2 2.5 3 3.5 40

5

10

15

20

25

Late Harvest Rye Early Harvest Rye Control

Visual Score

Dept

h (c

m)

Page 7: Introduction to  Matlab

Improved graphics

25

50

75

100

2006-2007

Mono cropDouble crop

25

50

75

100

2007-2008 GC

(%

)

2-Sept 3-Nov 4-Jan 7-Mar 8-May 9-July0

25

50

75

100

2008-2009

Page 8: Introduction to  Matlab

Customization

function theta_vg = vangenuchten(vgparams, matric)%VANGENUCHTEN returns the estimated water content vector corresponding to%the input vectors containing the matric potential and the function%parameters. The units of the matric potential and the units of the%parameter "alpha" must cancel.

theta_s = vgparams(1); %saturated water contenttheta_r = vgparams(2); %residual water contentn = vgparams(3); %shape factoralpha = vgparams(4); % inverse of air entry potential%m = 1 - 1/n;m = vgparams(5);

theta_vg = ((1+(-alpha*matric).^n).^(-m))*(theta_s - theta_r) + theta_r;

Page 9: Introduction to  Matlab

Efficiency and Speed• Excel spreadsheet with 106 data points = 8.8 Mb• Matlab data file with 106 data points = 0.4 Mb• “Consider the problem of inverting the covariance matrix of a first-

order autoregressive process with dimension n=1000 and correlation parameter 0.5 and unit innovation variance…. PC with a 400 MHz Pentium II processor running WinNT with 256 MB RAM.”

Program CPU Time in Seconds

Mathematica, uncompiled 127

Mathematica, compiled 99

R 77

MatLab V.5.3 R11 48

S-Plus Version 5.2 109

C++ 98

Fortran 79

http://www.stats.uwo.ca/faculty/aim/epubs/MatrixInverseTiming/default.htm

Page 10: Introduction to  Matlab

Disadvantages of Matlab

• Harder to learn than Excel

• Weaker on statistics than SAS– For example: no built-in “repeated measures”

procedure