5_pdfsam_2

# 5_pdfsam_2 - − with equal precedence left to right When...

This preview shows page 1. Sign up to view the full content.

Matlab cannot make sense out of just any command; commands must be written using the correct syntax (rules for forming commands). Compare the interaction above with >> 4 + 6 + ??? 4 + 6 + | Missing operator, comma, or semi-colon. Here, Matlab is indicating that we have made a syntax error, which is comparable to a misspelled word or a grammatical mistake in English. Instead of answering our question, Matlab tells us that we’ve made a mistake and tries its best to tell us what the error is. Precedence of operations (order of evaluation) Since several operations can be combined in one expression, there are rules about the order in which these operations are performed: 1. Parentheses, innermost first 2. Exponentiation ( ^ ), left to right 3. Multiplication (*) and division (/ or \ ) with equal precedence, left to right 4. Addition (+) and subtraction (
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: − ) with equal precedence, left to right When operators in an expression have the same precedence the operations are carried out from left to right. Thus 3 / 4 * 5 is evaluated as ( 3 / 4 ) * 5 and not as 3 / ( 4 * 5 ) . 2.2.3 Variables and Assignment Statements Variable names can be assigned to represent numerical values in Matlab . The rules for these variable names are: • Must start with a letter • May consist only of the letters a-z , digits-9 , and the underscore character ( _ ) • May be as long as you would like, but Matlab only recognizes the Frst 31 characters • Is case sensitive: items, Items, itEms, and ITEMS are all di±erent variable names. Assignment statement: Matlab command of the form: • variable = number • variable = expression 18...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern