9_pdfsam_2 - >> bolts = 18;...

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

View Full Document Right Arrow Icon
average_cost cost rivets bolts items screws >> whos Name Size Bytes Class average_cost 1x1 8 double array bolts 1x1 8 double array cost 1x1 8 double array items 1x1 8 double array rivets 1x1 8 double array screws 1x1 8 double array Grand total is 6 elements using 48 bytes Each variable occupies 8 bytes of storage. These variables each have a size 1x1 because they are scalars , as opposed to vectors or matrices. Redefning variables A variable may be redeFned simply by executing a new assignment statement involving the variable. Note that previously issued commands involving the redeFned variable won’t be automatically reevaluated. Example 2.3 Variable redefnition >> screws = 32;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: >> bolts = 18; >> rivets = 40; >> items = screws + bolts + rivets items = 90 >> screws = 36 screws = 36 >> items items = 90 After computing items , screws was changed to 36, overwriting its previous value of 32. Note that the value of items has not changed. Unlike a spreadsheet, Matlab does not recalculate the number of items based on the new value of screws . When Matlab performs a calculation, it does so using the values it knows at the time the requested command is evaluated. In this example, to recalculate items , the items assignment statement must be re-issued: 22...
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