MATLAB onramp Flashcards
State which key symbolises multiplication
*
State which key symbolises division
/
State what a semicolon means
A semi colon suppresses the output
State what pressing the up arrow does
Pressing the up arrow recalls previous commands
Describe how to name a matlab variable
A matlab variable must start with a letter and contain only letters, numbers and underscores
State how to clear all workspace variables
Type in the command “clear”
State how to clear the command window
Type in the command “clc”
State the matlab constant for π
pi
State the matlab function for absolute values
abs
State the matlab function for calculating eigenvalues
eig
State the matlab function for calculating square roots
sqrt
Describe an array
All matlab variables are called arrays - each variable can be more than one number.
Describe a scalar
A scalar is one number, ie a 1 by 1 array (1 row by 1 column)
Describe how to create arrays with multiple elements
Using square brackets, you can create arrays. Eg x = [3 5]
Describe how to create an array with elements in a single row (a row vector)
Separate the elements using a space or a comma
Describe how to create an array with elements in a single column (a column vector)
Separate the elements using a semicolon.
Describe how to create a matrix
Enter the matrix row by row, separating the rows by semicolons
Describe a short method of writing a row vector containing consecutive increasing integers
enter first:last (note you do not need square brackets)
Describe a short method of writing a row vector containing integers of a particular spacing
enter first:spacing:last
Describe how to enter a row vector of unknown spacing if you know the first and last numbers and the total number of columns
Using the linspace fucntion: linspace(first,last,number_of_elements) (note the use of commas)
Describe how to transpose a row vector to a column vector
( ‘ ) is the transpose operator. You can either transpose x or transpose the parenthesis of a row vector
Describe how to create a matrix of random numbers
Entering rand(a) where a will produce an a x a matrix of random numbers. Entering rand(a , b) will produce an a x b matrix of random numbers
Describe how to create a zero matrix
Entering zeros(a) where a will produce an a x a matrix of zeroes. Entering rand(a , b) will produce an a x b matrix of zeroes
Describe how to save a variable x to a given name
Enter “save foo x” to save variable x to a file called foo.mat
Describe how to load a saved variable of a given name
Enter “load foo” to load a file called foo.mat
Describe how to display the contents of of any variable
Enter the variable name
Describe how to extract values from an array
Using row,column indexing. Eg y = A(6,7) will give you the element in the 6th row and 7th column of matrix A and label it y
Describe the use of ‘end’
‘end’ refers to the end value in a row or column. You can also use end-1 to refer to the second to last value, etc
Describe the colon operator ( : ) when used as an index
( : ) specifies all the elements in that dimension. Eg x = A(2,:) creates a row vector with all the elements from the second row of A. x=A(1:3,:) creates a matrix containing the first, second and third rows of matrix A
Describe a single index value
A single index value can be used to reference a single element. Eg x=v(3) refers the the 3rd element of v when v is either a row or a column vector
Describe a single range of index values
UP TO 5.2