Solving biological problems with MATLAB Lecturer: Chen Keasar, 08-6477875 Office hours: 37/102 Sunday, 14:00-16:00.

Slides:



Advertisements
Similar presentations
A bit more about variables >> var1 = [ 1 2 3] var1 = >> var2 = var1 var2 = >> var1 = [4 5 6] var1 = >> var2 var2 =
Advertisements

CSE Spring 2015 INTERMEDIATE PROGRAMMING
Lecture 1: Intro to Computers Yoni Fridman 6/28/01 6/28/01.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
CS101- Lecture 11 CS101 Fall 2004 Course Introduction Professor Douglas Moody –Monday – 12:00-1:40 – – –Web Site: websupport1.citytech.cuny.edu.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
CSC 171 – FALL 2004 COMPUTER PROGRAMMING LECTURE 0 ADMINISTRATION.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
COMP 110 Introduction to Programming Mr. Joshua Stough August 22, 2007 Monday/Wednesday/Friday 3:00-4:15 Gardner Hall 307.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
COMP 14 – 02: Introduction to Programming Andrew Leaver-Fay August 31, 2005 Monday/Wednesday 3-4:15 pm Peabody 217 Friday 3-3:50pm Peabody 217.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Recitation 1 Programming for Engineers in Python.
CSE 131 Computer Science 1 Module 1: (basics of Java)
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
WEEK 1 CS 361: ADVANCED DATA STRUCTURES AND ALGORITHMS Dong Si Dept. of Computer Science 1.
TERMS TO KNOW. Programming Language A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks. Each language has.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
CS 1 •This is Computer Science 1. •Who is Professor Adams?
THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014
CSc 2310 Principles of Programming (Java) Dr. Xiaolin Hu.
1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
Welcome to CS 115! Introduction to Programming. Class URL Write this down!
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
Class 1: What this course is about. Assignment Read: Chapter 1 Read: Chapter 1 Do: Chapter 1 ‘workbook’ pages not finished in class Do: Chapter 1 ‘workbook’
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
Lecture 5 1.What is a variable 2.What types of information are stored in a variable 3.Getting user input from the keyboard 1.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
A (VERY) SHORT INTRODUCTION TO MATLAB J.A. MARR George Mason University School of Physics, Astronomy and Computational Sciences.
Intermediate 2 Computing Unit 2 - Software Development.
Introduction to Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Spring 2016 Statics - TAM 210 & TAM 211 Discussion 1 - Intro to Matlab 1.
Dr. Sajib Datta CSE Spring 2016 INTERMEDIATE PROGRAMMING.
Computer Programming for Engineers CMPSC 201C Fall 2000.
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Dr. Sajib Datta Jan 15,  Instructor: Sajib Datta ◦ Office Location: ERB 336 ◦ Address: ◦ Web Site:
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
Computer Application in Engineering Design
Introduction to Matlab
1-1 Logic and Syntax A computer program is a solution to a problem.
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Revision Lecture
Arrays and files BIS1523 – Lecture 15.
Introduction to C Topics Compilation Using the gcc Compiler
Java programming lecture one
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
Week 1 Gates Introduction to Information Technology cosc 010 Week 1 Gates
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
Assembler, Compiler, Interpreter
CS190/295 Programming in Python for Life Sciences: Lecture 1
Welcome to CS 1010! Algorithmic Problem Solving.
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
Assembler, Compiler, Interpreter
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
CSCI 203: Introduction to Computer Science I
Presentation transcript:

Solving biological problems with MATLAB Lecturer: Chen Keasar, Office hours: 37/102 Sunday, 14:00-16:00 Tutors: Mor Ben-Tov (Life Sciences) Office hours: 40/310 Wednesday 15:00-16:00 Yonatan Natan (Sde-Boker) Office hours: Sunday 15:00-16:00 Web page URL:

What will you learn in the course? Algorithms Building blocks for writing a MATLAB program Using MATLAB for mathematical applications Handling graphics in MATLAB

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

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

What do I do with MATLAB?

CLUSTERING

Generation of energy function

What is MATLAB MATLAB is a language MATLAB is an interpreter MATLAB is an integrated environment MATLAB is a product of MathWorks

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

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

What is MATLAB MATLAB is a language popSize=23 MATLAB is an interpreter (command window) >> popSize = 23 MATLAB is an integrated environment popSize=23

What is MATLAB MATLAB is a language popSize=23 MATLAB is an interpreter (command window) MATLAB is an integrated environment

What is MATLAB MATLAB is an integrated environment

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

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

Non-recommended variable names a b1 gc initialpopulationsize

Functions extend the language Specific Syntax: function output=functionName(input) …. the function itself … end Words of MATLAB language

function output=functionName(input) …. the function itself … end Any word you want. Becomes a new word in the language

function output=functionName(input) …. the function itself … end Any word you want. Known only within the function

function output=functionName(input) …. the function itself … end MATLAB code (may include function calls)

Our first function Motivation: populations parthenogenetic aphids

Our first function function 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

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

This is a bit too verbose

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?

The function’s value may be assigned to a variable (actually it is always assigned)

Variables defined in the command window are kept in memory.

You can see them all in the “Workspace” window

The function’s variable are recognized only within the function

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

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

A row vector may be transposed to a column vector

From vectors to matrices >> popParam= [ ; ] popParam = Indexing an array/matrix popParam (1,1) popParam (1,2) popParam (1,3) popParam (2,1) popParam (2,2) popParam (2,3)

popParam = >> popParam(1,1) ans = 24 >> popParam(2,2) ans =

popParam = >> popParam(1,2:3) ans = Note the colon! Here, it represents “to” Note, this is a vector >> ans(1) ans =

popParam = >> popParam(1,:) ans = Note the colon! Here, it represents “all”