lecture19_slides

lecture19_slides - Overview of today Today Review of...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Overview of today Today: Review of concepts from last time Statistics for differential expression analysis Formatted printing Reading from and writing to files in Matlab Start on visualizing data in Matlab Next week: - More visualizing data in Matlab - Methods for clustering gene expression data
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Conditions for matrices What if we are comparing matrices or vectors? Recall, the following are for scalars: a==b, a > b, a < b, a >= b, a <= b, a ~= b 0 1 0 0 0 1 1 0 0 1 2 5 1 2 6 u v == ? If you want to see if two matrices are identical, use the more general function isequal : >> isequal(u,v) ans = 0 >> v(1) = 1; v(3) = 5; isequal(u,v) ans = 1 conditionals.m
Background image of page 2
Multiple Conditions Expressing multiple conditions condition1 AND condition2: (a < b) & (c ~= d) condition1 OR condition2: (a < b) | (c ~= d) NOT condition1: ~ (a < b) To avoid ambiguity, it helps to use parentheses to group conditions, e.g. (condition1 AND ( (NOT condition2) OR condition3) ) Just like single conditions, multiple conditions can be stored to a variable: Recall that Perl uses double symbols for “and” and “or”: “&&”, “||”. Matlab gives you the option of using single or double symbols. They mean slightly different things, which we will not explore here. is_n_bw_4_and_7 = 0 is_m_bw_4_and_7 = 1 conditionals.m
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example with multiple conditions conditionals.m w = 1 4 25 Recall that both u and v are column vectors of length 3. 1 2 5 u = 1 2 5 v =
Background image of page 4
The “find” function A very useful function: “find” For 1-D matrices: i = find(matrix); For 2-D matrices: [i,j] = find(matrix); conditionals.m “find” takes as input a matrix or vector, and returns the location of the nonzero elements of that matrix or vector. ans = 0.3420 0.2897 0.3412 ans = 0.3093
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The “find” function A very useful function: “find” For 1-D matrices: conditionals.m “find” takes as input a matrix or vector, and returns the location of the nonzero elements of that 0.3420 0.2897 0.3412 ans = 0.3093 You can also use multiple conditions in the find function, for example if you would like to extract the indices of all elements of random matrix „A‟ greater than 0.2, but less than 0.7: [i,j] = find((A > 0.2) & (A < 0.7));
Background image of page 6
Logical indexing Logical indexing is shorter and faster than using “find” conditionals.m w = 1 4 25 ind = 1 0 1 ans = 1 25 ans = 0.3420 0.2897 0.3412
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Loops Just like Perl, there are two different kinds of loops: for <loop-var>=<start-val>:<increment>:<end-val> statements here… end while (condition) statements here… end Remember Perl‟s three “for loop” parts: (1) initialize, (2) condition that must be satisfied while looping, (3) how to update loop variable in between Matlab does not accept { } to wall statements in. Entire chain of loop statements must end with “end”. Perl requires { } around each group of statements.
Background image of page 8
For Loops Perl: Matlab: loops.m
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
More For Loops loops.m
Background image of page 10
While Loops loops.m
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Breaking Loops (new!) If you want to terminate a loop before it‟s finished, use the “break” statement: for <loop-var>=<start-val>:<increment>:<end-val>
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/21/2011 for the course CSCI 3003 taught by Professor Staff during the Spring '08 term at Minnesota.

Page1 / 50

lecture19_slides - Overview of today Today Review of...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online