You are on page 1of 2

Engineering 6 matlab

Matlab and octave are "interpreted" languages. Almost all other languages must be compiled. No compiling needed in matlab. It compiles it line by line Matlab history: It was written in the late 70's in university of new mexico. Matlab is short for Matrix Laboratory Matlab is great for: matrix operations, rapid development, image processing, instrumentation control, simulation Matlab is ok for parallel (distributed computing), iterative code "serial" Matlab is lousy for high performance code '%' symbol starts comment area for a line <command> ... three dots continue input to next line clear: clears all objects in workspace who: lists all objects in the workspace clear x y: clears value of objects x and y Matlab does not require you to declare variables or their types You can type in integers and doubles as numbers If you want to use alphanumeric text in Matlab, you need to enclose that text in single quotes Scripts: collection of commands executed in sequence written in the matlab editor memory: ram, disk drive, flash datapath: add/subtract, multiply, compare input --> memory -> output

4/7/2011 x = matrix x' = transposed matrix. ' is the command to transpose it from row to column or column to row 4/12/2011 - plotting plot(x,y); x,y are 1-D vectors of the same length example: plot([1,2,3], [5,2,0]); It will plot: (1,5), (2,2), (3,0) to title graph: title('hwk2.2'); to label x axis: xlabel('sdfjdskg'); to label y axis: ylabel('sjdgsg'); to turn on grid: grid on; hold on; hold off; for multiple graphs on one plot axis([xmin, xmax, ymin, ymax]). For example: axis([0 4 0 6]) To add color and patterns, add argument to plot command: b for blue, g for green, k for black etc. marker style: a period for point, o for circle, x for "x" line style: - solid, : dotted, -- dash for example: plot([1,2,3], [5,2,0], 'bx--') a, b are matrices. a*b 1. linear algebra multiplication (a*b) 2. term by term multiplication (a.*b)

Use the figure command when working with multiple graphs April 14, 2011 For a paper: 1. Keep in mind the point or story 2. Write clearly and accurately. Okay to break almost any other rule for more clarity 3. Minimize ink - text, figures, graphs, line arrays Organization: 1. Get data 2. Graphs, figures, tables, 3. Outline (ppt) 4. Detailed outline 5. Write text 6. Conclusion, abstract, title Boolean Logic/Algebra on or off, 0 or 1, true or false 1. Invert/NOT/complement: x01 inversion: x' 1 0 2. AND (syntax: X&Y) if x and y are both true, the output will be true. If not, output is 0 3. OR operator (syntax: X|Y or X+Y) if either x or y is true, the output will be true. It will be true if both x and y are true. 4. Exclusive (OR, XOR) if either x or y is true, the output will be true. However, if both x and y are true, the output will be false Arrays 1. A(2,3) - A is the matrix name, 2 is the row index, 3 is the column index. It will give you the value in rown 2, column 3 2. A(,:3) - gives us the entire third column. 3. A(3,:) - gives us the entire third row 4. Syntax: A~= 0 translates to "A not equal to zero" 5. strcat(x,y) to glue strings 6.