5_pdfsam_2 - − ) with equal precedence, left to right...

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

View Full Document Right Arrow Icon
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 Frst 2. Exponentiation ( ^ ), left to right 3. Multiplication (*) and division (/ or
Background image of page 1
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

This note was uploaded on 03/07/2010 for the course ENG 101 taught by Professor Chang during the Summer '09 term at 東京国際大学.

Ask a homework question - tutors are online