02-Basic-MATLAB-4UP

02-Basic-MATLAB-4UP - InteractiveMATLAB Managing the...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: InteractiveMATLAB Managing the workspace Scripts Basic M ATLAB Dhavide Aruliah UOIT MATH 2070U c D. Aruliah (UOIT) Basic MATLAB MATH 2070U 1 / 23 InteractiveMATLAB Managing the workspace Scripts Basic M ATLAB 1 Interactive computing in MATLAB 2 Managing the MATLAB workspace 3 MATLAB scripts c D. Aruliah (UOIT) Basic MATLAB MATH 2070U 2 / 23 InteractiveMATLAB Managing the workspace Scripts Entering expressions interactively We can calculate numbers in a sequence of assignment statements >> a = 4; % assigns value 4 to variable a >> a = a + 1.42644 % assigns value 5.42644 to variable a >> b = a, b = ... % command continued on next line >> 3 >> command prompt ; statement separator (without output) , statement separator (with output) ... continuation of statement on next line ans answer, last value calculated % comment symbol; characters to right ignored (Extra spaces dont matter) c D. Aruliah (UOIT) Basic MATLAB MATH 2070U 4 / 23 InteractiveMATLAB Managing the workspace Scripts Typesetting expressions for programs Use ASCII (typewriter) characters for programming. Arithmetic operations of addition, subtraction, multiplication, division, and exponentiation are + ,- , * , / , and ^ respectively e.g. the expressions below have are typeset as specified x + y x+y b- a b-a uv = u v u*v m / n = m div n = m n m/n a k a^k (Some languages allow a**k for a k , e.g., MAPLE & Fortran) c D. Aruliah (UOIT) Basic MATLAB MATH 2070U 5 / 23 InteractiveMATLAB Managing the workspace Scripts Identifiers in M ATLAB Identifier : generic term for variable name in programming Rules for identifiers in MATLAB: 1 Identifiers are case sensitive (e.g., Alpha 6 = alpha ) 2 Identifiers can contain up to 63 characters. Any character beyond the 63rd is ignored. 3 Identifiers must start with a letter, followed by any number of letters, digits, or underscores. Punctuation characters are not allowed. (e.g., foo 4 is allowed, but not foo4 or 4foo ) Use sensible identifiers term to clarify code, e.g., area = pi * radius * radius volume = length * height * width amount owing = principal + interest c D. Aruliah (UOIT) Basic MATLAB MATH 2070U 6 / 23 InteractiveMATLAB Managing the workspace Scripts Syntax for common mathematical functions sqrt(x) square root x nthroot(x,n) n th root n...
View Full Document

Page1 / 5

02-Basic-MATLAB-4UP - InteractiveMATLAB Managing the...

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