math245lab01

math245lab01 - Math245 Lab set #1 Fall 2008 Introduction to...

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

View Full Document Right Arrow Icon
Math245 Lab set #1 Fall 2008 Page 1 Introduction to Matlab Basics 1 Matlab desktop 1. Variable assignment and arithmetic operations You can create any variables by assigning values to it in the form: (your variable name ) = (expression) General rule here is the notation " = " is NOT the same as the mathematical equality. " = " is called assignment operator. Your specified (expression) in rhs is assigned to (your specified variable name). Like using your calculators, you can do arithmetic operations by using arithmetic operators, i.e., + : addition, - : subtraction, * : multiplication, / : division, and ^ : exponentation. You can also use standard mathematical functions (e.g., sin, cos, exp, tanh, etc.) provided in Matlab package. Example 1: a = 1.0 a = 1 Command window (you put matlab command in here) Command history window (shows history of command) File list of current working directory Current working directory
Background image of page 1

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

View Full DocumentRight Arrow Icon
Math245 Lab set #1 Fall 2008 Page 2 a = a + 1 % This statement assigns "a+1" to "a". ("a" is renewed by the value "a+1") a = 2 pi % π is already defined in Matlab package. ans = 3.1416 c = cos(a*pi)^2 + exp(a/2.0) – 1.0 % exp(a/2) means /2 a e c = 2.7183 So far we have created variables a, c and ans in Matlab work space (computer memory). To check what variables we have in the work space, just type ‘who’ or ‘whos’. who Your variables are: a ans c whos Name Size Bytes Class a 1x1 8 double array ans 1x1 8 double array c 1x1 8 double array Grand total is 3 elements using 24 bytes To clear all the variables in the work space you simply put ‘clear’ command.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/08/2009 for the course MATH 245 at USC.

Page1 / 7

math245lab01 - Math245 Lab set #1 Fall 2008 Introduction to...

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