Matlab Class Home
Class Outline
Previous Class
Next Class
Evaluation 2
Goal for Week 2: Create MATLAB variables, Assign values and Use variables for calculations
Summary of new tools and commands.
*
is multiplication operator which does a "matrix multiply" from linear algebra. The details of this operation are explained in task 2.5.
.*, ./
is the operator which multiplies or divides each element by the corresponding values in lists and tables.
.^
is the exponentiation operator which raises each value of a variable in the list to a power. For example, 2.^2 is two squared.
;
indicates the end of a row of values.
'
indicates a matrix transpose.
:
is used to create a list of variables with constant intervals, say the integers from 1 to 5. It also indicates (by itself) all entries in a list.
pi
is a built-in variable which is defined as the ratio of the circumference of a circle to its diameter.
[ ]
is a concatenation operator which combines values within the symbols.
( )
is a grouping operator in arithmetic. It is also used to identify certain members of lists and table.
' '
defines a character string.
disp(string)
is a function which displays the enclosed character string in the command window.
num2str(number)
converts the value of a numerical variable to a character string. This is used with
disp()
to show values of variables.
zeros(r,c)
creates a variable with the desired rows (r) and columns (c) and assigns all the initial values to be zero.
clear variable
removes the named variable from the work space.
who, whos
gives information on variables that are currently defined.
Tasks for Week 2
Tasks
1
Create a variable holding the radius of a circle, calculate the circumference and area, display the results.
2
Create two variables holding widths and heights, separately, of five rectangles. Calculate the areas of these rectangles.
3
Create an array (table) variable which has the width, height and area as columns, display the values in the third row of this table.
4
Create a variable holding a list of 8 zeros, initialize the values with even integer values starting at 12 and increasing by 2 each time. Calculate the square of these values, display the sixth value and its square.
5
Create a column vector (C) and a row vector (R) each with three values, determine the results of C*R and R*C.
6
Finding and fixing errors.
Matlab Class Home
Class Outline
Previous Class
Next Class
Evaluation 2
email: J. Klinck