solving biological problems with matlab lecturer: chen keasar, e-mail:...
TRANSCRIPT
![Page 1: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/1.jpg)
Solving biological problems with MATLAB
Lecturer: Chen Keasar, e-mail: [email protected] hours: 37/102 Sunday, 14:00-16:00
Tutors: Mor Ben-Tov (Life Sciences) E-mail: [email protected]
Office hours: 40/310 Wednesday 15:00-16:00
Yonatan Natan (Sde-Boker) E-mail: [email protected] Office hours: Sunday 15:00-16:00
• Web page URL:http://lhttp://moodle.bgu.ac.il/moodle/
![Page 2: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/2.jpg)
What will you learn in the course?
• Algorithms
• Building blocks for writing a MATLAB program
• Using MATLAB for mathematical applications
• Handling graphics in MATLAB
![Page 3: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/3.jpg)
The rules of this course
• No formal pre-requisite
• Math course ( מערכות של or equivalent) is מתמטיקהassumed
• lecture notes on web - print and bring
• Tutorials – central role in the course
• Start in class, complete at home, submit every week (through the web site)
• Each student submits own independent work
• The use of the Forum of course is allowed, but no code
• Missing tutorials (e.g., Miluim), can be exempt but it’s your interest to submit even if later3
![Page 4: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/4.jpg)
The rules of the game (cont.)
• Students from Sede Boqer campus will have tutorial there
• The tutors will instruct you exactly how tom submit tutorial – MUST follow instructions
• Tutorials not submitted accordingly – will not be accepted !
• Final project – selected from a list - or request your own project (no tater than week 5 of the semenster).
• After project submission – an oral exam in front of computer on the project
• Final grade – 35% tutorials, 65% final exam
![Page 5: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/5.jpg)
What do I do with MATLAB?
![Page 6: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/6.jpg)
CLUSTERING
![Page 7: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/7.jpg)
![Page 8: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/8.jpg)
![Page 9: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/9.jpg)
![Page 10: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/10.jpg)
![Page 11: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/11.jpg)
![Page 12: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/12.jpg)
![Page 13: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/13.jpg)
![Page 14: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/14.jpg)
![Page 15: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/15.jpg)
![Page 16: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/16.jpg)
![Page 17: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/17.jpg)
![Page 18: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/18.jpg)
![Page 19: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/19.jpg)
![Page 20: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/20.jpg)
![Page 21: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/21.jpg)
Generation of energy function
![Page 22: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/22.jpg)
![Page 23: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/23.jpg)
![Page 24: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/24.jpg)
![Page 25: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/25.jpg)
![Page 26: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/26.jpg)
What is MATLAB• MATLAB is a language
• MATLAB is an interpreter
• MATLAB is an integrated environment
• MATLAB is a product of MathWorks
![Page 27: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/27.jpg)
What is MATLAB• MATLAB is a language
popSize=23
is a statement in this language.
It means:
1. Allocate some space in the computer memory.
2. Tag this space “popSize”.
3. Store the number 23 in that space.
• MATLAB is an interpreter
• MATLAB is an integrated environment
![Page 28: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/28.jpg)
What is MATLAB• MATLAB is a language
popSize=23
• MATLAB is an interpreter
A program that:
1. reads MATLAB statements
2. Translates them to machine language
3. Executes them.
• MATLAB is an integrated environment
![Page 29: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/29.jpg)
What is MATLAB• MATLAB is a language
popSize=23
• MATLAB is an interpreter (command window)
>>
popSize =
23
• MATLAB is an integrated environment
popSize=23
![Page 30: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/30.jpg)
What is MATLAB• MATLAB is a language
popSize=23
• MATLAB is an interpreter (command window)
• MATLAB is an integrated environment
![Page 31: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/31.jpg)
What is MATLAB• MATLAB is an integrated environment
![Page 32: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/32.jpg)
Programming with MATLAB
Basic components in computer program
takes input -> operates on it -> gets output
Various Input/Output methods – later
simplest input:
Allocating a value to a variable, e.g.,:
a=2
popSize=23
![Page 33: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/33.jpg)
Variable Names• Variables start with a letter
• Can continue with more letters, digits etc.
• Not longer than 31 characters
• Make names easy to remember
• make sure no typos
• MATLAB is case sensitive
• popSize is different from PopSize or popSize1
![Page 34: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/34.jpg)
Non-recommended variable names a
b1
gc
initialpopulationsize
![Page 35: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/35.jpg)
Functions extend the language
Specific Syntax:
function output=functionName(input)…. the function itself …end
Words of MATLAB language
![Page 36: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/36.jpg)
function output=functionName(input)…. the function itself …end
Any word you want. Becomes a new word in the language
![Page 37: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/37.jpg)
function output=functionName(input)…. the function itself …end
Any word you want. Known only within the function
![Page 38: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/38.jpg)
function output=functionName(input)…. the function itself …end
MATLAB code (may include function calls)
![Page 39: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/39.jpg)
Our first functionMotivation: populations parthenogenetic aphids
![Page 40: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/40.jpg)
Our first functionfunction popSize2 = popDynam(popSize1)
birthRate = 0.2
deathRate = 0.1
birth = popSize1 * birthRate
death = popSize1 * deathRate
change = birth - death
popSize2 = popSize1 + change
end
We will save it in a file popDynam.m
![Page 41: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/41.jpg)
![Page 42: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/42.jpg)
What had happened?The MATLAB interpreter replaced popSize1 by 23 and executed the lines one by one.
function popSize2 = popDynam(popSize1)
birthRate = 0.2
deathRate = 0.1
birth = popSize1 * birthRate
death = popSize1 * deathRate
change = birth - death
popSize2 = popSize1 + change
end
23
23
23
23
![Page 43: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/43.jpg)
This is a bit too verbose
![Page 44: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/44.jpg)
Our first function (fixed)
function popSize2 = popDynam(popSize1)
birthRate = 0.2;
deathRate = 0.1;
birth = popSize1 * birthRate;
death = popSize1 * deathRate;
change = birth – death;
popSize2 = popSize1 + change;
end Is this the shortest way I could write the function?
![Page 45: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/45.jpg)
![Page 46: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/46.jpg)
![Page 47: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/47.jpg)
![Page 48: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/48.jpg)
The function’s value may be assigned to a variable
(actually it is always assigned)
![Page 49: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/49.jpg)
Variables defined in the command window are kept in memory.
![Page 50: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/50.jpg)
You can see them all in the “Workspace” window
![Page 51: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/51.jpg)
The function’s variable are recognized only within the function
![Page 52: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/52.jpg)
Some other aphids may have different birth and death rates.
function popSize2=popDynam(popSize1, birthRate, deathRate)
birth = popSize1 * birthRate;
death = popSize1 * deathRate;
change = birth - death;
popSize2 = popSize1 + change;
end
![Page 53: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/53.jpg)
We may want to know the number of births and deaths
function pop = popDynam(popSize1, birthRate, deathRate)
birth = popSize1 * birthRate;
death = popSize1 * deathRate;
change = birth - death;
popSize2 = popSize1 + change;
pop = [popSize2 birth death];end
Row vector
![Page 54: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/54.jpg)
![Page 55: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/55.jpg)
A row vector may be transposed to a column vector
![Page 56: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/56.jpg)
From vectors to matrices
>> popParam= [24 0.2 0.1; 38 0.25 0.05]popParam = 24.0000 0.2000 0.1000 38.0000 0.2500 0.0500
Indexing an array/matrixpopParam(1,1) popParam(1,2) popParam(1,3)popParam(2,1) popParam(2,2) popParam(2,3)
![Page 57: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/57.jpg)
popParam = 24.0000 0.2000 0.1000 38.0000 0.2500 0.0500
>> popParam(1,1)ans = 24
>> popParam(2,2)ans = 0.2500
![Page 58: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/58.jpg)
popParam = 24.0000 0.2000 0.1000 38.0000 0.2500 0.0500
>> popParam(1,2:3)ans = 0.2000 0.1000
Note the colon! Here, it represents “to”Note, this is a vector>> ans(1)ans = 0.2000
![Page 59: Solving biological problems with MATLAB Lecturer: Chen Keasar, e-mail: chen@cs.bgu.ac.ilchen@cs.bgu.ac.il 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00](https://reader036.vdocuments.net/reader036/viewer/2022062423/56649ec65503460f94bd25d9/html5/thumbnails/59.jpg)
popParam = 24.0000 0.2000 0.1000 38.0000 0.2500 0.0500
>> popParam(1,:)ans = 24.0000 0.2000 0.1000
Note the colon! Here, it represents “all”