L2_basics_stud 2 - CGN 3421 - Computer Methods Gurley...

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

View Full Document Right Arrow Icon
CGN 3421 - Computer Methods Gurley Lecture 2 MATLAB basics page 9 of 15 Lecture 2 MATLAB basics Common tools: % and ; % indicates a comment, not a command to be executed MATLAB ignores comments. % can be placed at the end of an executable line to comment on that line >> weight=input(‘give weight’); %getting weight a ; following an assignment will suppress display of the command result. ; signals the end of a single command, and can be used to separate multiple sequential statements on the same line. >> density = 1.25; diameter = 10.2; Operators + Addition - Subtraction * Multiplication / Division ^ Power ' Complex conjugate transpose (swaps columns and rows) ( ) Specify evaluation order Order of Operations ( ) ^ highest level, first priority * / next priority level + - last operations to be performed >> y = 2; x = 3 * y^2 Ans: 12 >> y = 2; x = (3*y)^2 Ans: 36 >> y = 2; x = 3 * y + 2 Ans: 8 >> z = 3*6+6*2/4 Ans: 21 >> x = 5^2/2 Ans: 12.5
Background image of page 1

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

View Full DocumentRight Arrow Icon
CGN 3421 - Computer Methods Gurley Lecture 2 MATLAB basics page 10 of 15 Order of Operations Example Express the quadratic formula in MATLAB Look at the following expressions. Identify which one will properly express the above equation. For the ones that don’t work, specify all the reasons it won’t work. >> x = -B + sqrt B^2 - 4*A*C / 2A % ??? >> x = -B + (B*B - 4*A*C)^(0.5)/2*A % ???
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/10/2011 for the course CGN 3421 taught by Professor Long during the Spring '08 term at University of Florida.

Page1 / 7

L2_basics_stud 2 - CGN 3421 - Computer Methods Gurley...

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

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