PH15720 Laboratory Techniques - An Introduction to MATHCAD Lecture 2
Introduction Review of Last Week Variables Names for Things Using Units Text areas & comments
Review of Last Session What, Why & Wherefore ? Starting MathCAD Simple calculations Saving work to M: drive ing worksheets
Variables #1 Storage for numbers in MathCAD Write formulae without using ‘magic numbers’ Do not re-type intermediate results Simplifies changing parameters
Use of variables - Example Compare the 2 solutions to a problem below Which is clearer ? Which is easier to change parameters ?
Variables #2 Variable set by using := Assignment operator ( := ) created by colon ( : ) key Declares the variable and sets its value to
Variables #3 Variables displayed by = sign Press = key If variable already defined, MathCAD will print value = Otherwise MathCAD will create assignment operator & placeholder for you to define value :=
Names for Things Very Important step in problem solving Applicable to all problems Applicable to all solution methods Develop convention & stick to it
Naming convention #1 Make names descriptive Use standard physics nomenclature UseCamelCapitalisation Examples: MRocket0 : initial mass VRocketFinal : final velocity Problem should suggest names
Naming Convention #2 Keep names short Use comments to explain names Don’t try & put spaces in names Avoid using names already used for mathematical/physical constants (unless you mean it !) g,c,e,q, MathCAD will warn you
Naming Convention #3 Good examples: MBallA := 1.7 kg Mass of Ball A vBallA0 := 23 m/s Velocity of Ball A at t=0 VResA0 := 12 volt Voltage across Resistor A = 12V at t=0
Naming Convention #4 Bad examples: A := 7 m/s No clue as to physical quantity Probably too short (unless diagram) Conflicts with A = Ampere v TheBallThrownByJohn := 17 m/s Way too long g := 19 Redefined acceleration due to gravity
Greek Letters Enter into variables etc by: Select from Greek toolbar Type corresponding roman character + = Enter into text regions (comments) by changing to symbol font
Using UNITS #1 All variables in MathCAD may have units attached to them Units propagate through calculations MathCAD checks to ensure ‘sanity’ Results may be manipulated to desired units
Using UNITS #2 To enter units: Assign a variable (Name + :) Press * to introduce multiplication Either: Enter units if you know them Press or units button to bring up selection dialog
Using units #3 Units displayed on result Many conversions possible
Using Units #4 To convert units of result Select placeholder after result Type/select desired units for result MathCAD will scale result to new units. Will add extra terms if dimensions wrong Placeholder
Text Regions #1 Very Important to: Introduce problem Introduce & explain variables Explain solution method Introduce & Explain answer
Text Regions #2 Text regions added by: Insert|Text Region “ key Typing a comment. MathCAD will convert the text to a text region when the first space is typed. Text regions moved/resized with mouse – watch cursor change