an introduction to matlab - uclaan introduction to matlab day 3 simon mitchell...

30
An Introduction to MATLAB Day 3 Simon Mitchell [email protected]

Upload: others

Post on 28-May-2020

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

An Introduction to MATLABDay 3

Simon [email protected]

Page 2: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Day 2:∗ While loops∗ Break statements∗ Vectors∗ Higher dimensional matrices∗ Sorting∗ Cell Arrays∗ Functions∗ File input and output

Page 3: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Plotting

Page 4: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Plotting

[-100:STEPSIZE:100]

Page 5: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Plotting

xlabel(STRING); ylabel(STRING); title(STRING); grid on; axis equal;

Page 6: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Plotting Multiple Graphs

hold on;

Page 7: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Plotting Multiple Graphs

hold on;

Page 8: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Changing the renderer

hold on;

Page 9: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Setting Axis Scales

>> axis([xLow xHigh yLow yHigh]);

Page 10: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

SubPlots

>> subplot(n,m,p);Plot n x m grid of plots and choose plot p.

Page 11: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Legend location

Page 12: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Legend location

Page 13: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Bar Graphs

Page 14: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Bar Graphs

Page 15: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

3 Dimensional Plots

Meshgridgenerates all possible x and y coordinates in a range

Page 16: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Editing plots

There is much, much more to learn about editing and formatting plots.

Play with the ‘property editor’Anything you can do in the property editor you can do with code.

Page 17: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Solving Equations

solve(equations, variable)

Page 18: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Systems Biology Modeling

Simulated biochemical systems using MATLAB• Test and generate hypotheses• Fewer and better experiments• Mechanistic explanation for results!• Accessible• Translational

Page 19: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Systems Biology Modeling

What is the rate of change of A?

The rate of change of A is equal to the rate of reaction R1

R1

What is the rate of reaction R1 proportional to?

A

B

A

BAB

Page 20: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Systems Biology Modeling

What is the rate of change of A?

R1A

B

A

BAB

Page 21: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Systems Biology Modeling

What is the rate of change of A?

R1A

B

A

BAB

Page 22: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

R1A

B

AB

AB

Page 23: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

R1A

B

AB

AB

Page 24: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

R1A

B

AB

AB

Page 25: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

R1A

B

AB

ABC

R2

Page 26: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

R1A

B

AB

ABC

R2

Page 27: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Debugging

Breakpoints

Page 28: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Breakpoints

BreakpointsHover over variables to view their contents

Step through line by line

Arrow indicates position in the code

Page 29: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Combining Everything!

R1A

B

AB

ABC

R2

Page 30: An Introduction to MATLAB - UCLAAn Introduction to MATLAB Day 3 Simon Mitchell Simon.Mitchell@ucla.edu. Day 2: ∗ While loops ∗ Break statements ∗ Vectors ∗ Higher dimensional

Continued Learning - Thanks

Selling out:

http://www.mathworks.com/[email protected]