CSE1010 Midterm

¡Supera tus tareas y exámenes ahora con Quizwiz!

processor (Ch.1)

- circuits that process a list of desired calculations - runs the computer's programs, reading, and executing instructions from memory, performing operations, and reading/ writing data from/ to memory

A valid identifier consists of ... (Ch.2)

- sequence of letters - digits (0-9) - underscores - must start with a letter

disk (Ch.1)

- stores files and other data, such as program files, office docs, etc. - non-volatile

RAM [random-access memory] (Ch.1)

-temporarily holds data read from storage and any address can be accessed much faster than a disk -able to access any memory location quickly and in arbitrary order -volatile

byte (Ch.1)

8 bits, memory size is typically listed as this

Switch (Ch.9.7)

A switch statement provides a method to more clearly represent such branching. A switch statement has the form: switch (expression) case caseExpr1 % statements to execute if expression equals caseExpr1 case caseExpr2 % statements to execute if expression equals caseExpr2 % (and expression does not equal caseExpr1) % Additional case statements should go here. otherwise % statements to execute if no cases match end

2D Array and Matrix (Ch.7.1)

A two-dimensional array or 2D array has elements arranged into rows and columns. In mathematics, a 2D array is commonly called a matrix. A programmer can generate a 2D array by creating a matrix consisting of row arrays separated by semicolons. Each row must contain an equal number of columns. Ex: GoogleGames = [ [1, 2, 3]; [4, 5, 6 ]] You an access a specific element in the array as myArray(row, column). Ex: GoogleGames(2, 3)

if and end (Ch.9.4)

An if statement supports a single branch and has the form: if (expression) % Branch taken: Statements to execute when the expression is true end % Statements here will execute after the above if statement, regardless of whether the branch is taken If the expression evaluates to true, the statements between the if statement and the closing end statement will be executed.

if-else and else (Ch.9.4)

An if-else statement includes an else part that will execute when the if statement's logical expression evaluates to false. An if-else statement has the following form: if (expression) % Statements to execute when expression is true else % Statements to execute when expression is false end % Statements here execute after the if-else

Recalling Terms such as Indexing Array, (Ch.7.4)

An indexing array is an array used as an index, while the indexed array is the array being accessed by the program. An integer indexing array is an indexing array that consists of integers.

end (Ch.4)&(Ch.7.7)

Chap 4 - a keyword that always refers to the last element of a one-dimensional array Chap 7 - the end keyword can be used as an index for a 2D array. For example, given matrixA is [10, 20, 30; 40, 50, 60], then matrixA[ 2, 1 ] returns the element in row 2, column 1, namely 40. Row 2 is the last row. If the intent is in fact to return the element in the last row and column 1, then a clearer and more general expression is matrixA[end, 1]. End can appear as the row index to indicate the last row, or as the column index to indicate the last column.

Comparing Floating-Point Numbers for Equality (Ch.9.6)

Commonly a programmer wishes to compare two numbers for equality, as in num == 0. However, when those numbers are floating-point numbers, such equality comparisons may not behave as expected due to the inability of a variable to exactly represent desired numbers. The problem is that a computer can not store every floating-point number exactly, due to using a limited number of bits. The small rounding errors can mean that two numbers that should be equal are not exactly equal, though they may be very close. A common error is to compare floating-point numbers using equality. Sometimes such equality comparison will work (for example, (0.1 + 0.1) == 0.2 yields true), but commonly the comparison fails (for example, (0.1 + 0.2) == 0.3 yields false).

if-elseif-if (Ch.9.5)

Commonly, more than two branches are required, in which case if-elseif-else statements can be used having the following form: if (expr1) % Statements to execute when expr1 is true % Execution continues after end elseif (expr2) % Statements to execute when expr1 is false and expr2 is true % Execution continues after end elseif (expr3) % Statements to execute when expr1 and expr2 are false and expr3 is true % Additional elseif statements would go here. else % Statements to execute if all above expressions are false end % Statements here will execute after the above branch statement

Mod(divided, divisor) (Ch.5.3) Ex1: What is mod(3,2)? Ex2:What is mod(3,-2)?

Defined as mod(x,y) = x − (floor(x/y) * y). The floor function produces an integer that is rounded towards minus infinity. Ex1: +1, The sign of the modulus function equals the sign of the divisor. The divisor 3 is positive. Ex2: -1, The sign of the modulus function equals the sign of the divisor. The divisor -2 is negative.

Rem(divided, divisor) (Ch.5.3) Ex1: What is rem(3,2)? Ex2: What is rem(3,-2)?

Defined as rem(x,y) = x − (fix(x/y) * y), where x is the dividend and y is the divisor (provided y is not zero). The fix function produces an integer rounded towards zero. Ex1 and Ex2: +1, The sign of the remainder function equals the sign of the dividend. The dividend 3 is positive.

5,7,9

Divya

Logical Expressions (Ch.9.3)

Expressions using logical operators are known as logical expressions. Note that each operand of a logical operator may be a logical expression, as in (usrAge > 16) & (drunk | drugged), where usrAge is a numerical variable and drunk and drugged are logical variables.

mean(x) (Ch.5.4)

Function calculates the arithmetic mean. Which is the sum of a list of numbers divided by the number of elements in the list. Also referred to as the average. The mean is indicated by the Greek letter µ.

max(x) (Ch.5.4)

Function max calculates maximum in a list of numbers. Ex: The command [maxVal, maxValIndex] = max(dataArray) stores the maximum value in array dataArray into the variable maxVal, and stores the index of that maximum value into the variable maxValIndex. If the array contains more than one element with the maximum value, max returns the index of the first element with that value.

median(x) (Ch.5.4)

Function median calculates the median of a list of numbers ( "middle value"). The median is the middle entry in the list after sorting the list into increasing order.

min(x) (Ch.5.4)

Function min calculates minimum in a list of numbers.

mode(x) (Ch.5.4)

Function mode calculates the mode, which is the value that appears most often in a set of data.

range(x) (Ch.5.4)

Function range calculates the range of a set of numbers, which is the smallest number subtracted from the largest number.

std(x) (Ch.5.4)

Function std calculates the standard deviation that describes how much variation from the mean exists in the data. The std indicated by the Greek letter σ.

Horzcat and Vertcat (Ch.7.3)

Horizontal concatenation requires the same number of rows, so that each corresponding row can be concatenated. Differing numbers of rows generates a horzcat error. Similarly, vertical concatenation requires the same number of columns, else a vertcat error is generated.

left-to-right (Ch.9.3)

If more than one operator of equal precedence could be evaluated, evaluation occurs left to right. Thus, a | b | c evaluates as (a | b) | c.

Examples of input/ output devices (Ch.1)

Input Devices - keyboard - mouse -touch pad -touch screen -scanners -microphone Output Devices -monitors -printers -speakers

( ) (Ch.9.3)

Items within parentheses are evaluated first.

| (Ch.9.3)

Last to be evaluated is or.

Out-of-Range Indices (Ch.7.2)

MATLAB generates an error message when a program reads an element outside the range of an existing array. Ex: if myArray is a 3×3 array, then if row-indexing is used myVal = myArray(4,4) yields the error message. If linear indexing is used, an out-of-range index during a read generates an error. In contrast, if a program assigns a value to an array element outside the range of an existing array using row-column indexing, then the interpreter re-sizes the array to accommodate the new element. Ex: If myArray is a 3×3 array, then myArray(5,5) = 101 re-sizes the array to a 5×5 array.

~a -- (Logical Operator) not(a) -- (Equivalent Operation) (Ch.9.3)

Negates or complements the value of a, returning true if a is false, and vice versa.

Rem and Mod Functions Differences(Ch.5.3)

Rem: The sign of the rem function is always the same as the sign of the dividend x. Mod:The sign of the mod function is always the same as the sign of the divisor y. If the divisor y is positive, the modulus function "approaches the number from -∞". For example, mod(9,3) equals 0, mod(10,3) equals 1, mod(11,3) equals 2 , mod(12,3) equals 0, and so on. If the divisor y is negative, the modulus function "approaches the number from +∞". For example, mod(9,-3) equals 0, mod(10,-3) equals -2, mod(11,-3) equals -1, mod(12,-3) equals 0, and so on.

a & b -- (Logical Operator) and(a,b) -- (Equivalent Operation) (Ch.9.3)

Returns true if a and b are true, meaning both are true.

xor(a,b) -- (Equivalent Operation) (Ch.9.3)

Returns true if a is true or b is true but not both, i.e., if exactly one of a or b is true. Known as exclusive or or xor (the x comes from eXclusive).

a | b -- (Logical Operator) or(a,b) -- (Equivalent Operation) (Ch.9.3)

Returns true if a or b is true, meaning either is true (or both).

isinf(x) (Ch.9.3)

Returns true if x is +Inf or -Inf; otherwise, returns false.

isnan(x) (Ch.9.3)

Returns true if x is NaN (Not-a-Number); otherwise, returns false.

isfinite(x) (Ch.9.3)

Returns true if x is finite; otherwise, returns false. For example, isfinite(Inf) is false, and isfinite(10) is true.

any(x) (Ch.9.3)

Returns true if x is nonzero; otherwise, returns false.

Array Reshaping(Ch.7.6)

Sometimes data that is initially represented as a list is better represented as a table. To accomplish this transformation in MATLAB, the single colon operator can be used to take the elements of a 1D array and write them into a 2D array. This is known as array reshaping. Reshaping is done by using a single colon index on the left hand side of an assignment statement.

Row-Column Indexing and Indices(Ch.7.2)

The conventional approach to index an element in a 2D array is row-column indexing. The programmer specifies someArray(m, n) to access the element in row m, column n. The integers m and n are known as the indices of the (m,n) array element. Ex: cityRain = 100, 98, 97 77, 78, 75 56, 58, 61 What value results from cityRain(1, 3)? The first row is 100, 98, 97. That row's third column is 97.

Logical Data Type, True and False (Ch.9.1)

The logical data type is a value that is either true (indicated by a non-zero number, typically 1) or false (indicated by the number 0). Logical variables can be used to test a logical state, namely whether something is either true or false, or to hold the outcome of a relational operation, which is discussed elsewhere.

case and otherwise (Ch.9.7)

The program will evaluate the switch statement's expression, compare the resulting value with the expression for each case, executing the first matching case's statements, and then jumping to the end. If no case matches, then the otherwise case's statements are executed. The switch statement's expression is a scalar value or a string. The cases' expressions is either a scalar, string, or cell array (discussed elsewhere).

Binary Operators (Ch.9.3)

The relational operators and logical operators, except for ~, are binary operators, meaning they take two operands (from the left and right) and evaluate to true or false.

Deleting Rows, Columns and a Single Array(Ch.7.6)

The single colon index with the empty array operator [] can be used to delete entire rows or columns in 2D arrays. For example, sampleMatrix(:,2) = [] deletes the second column of sampleMatrix. A programmer won't want to delete a single array element in a 2D array, because deleting an element would destroy the shape of the array. A common error is to attempt to use row-column indexing in an assignment to the empty array operator (for example, sampleMatrix(2,2) = []), to delete a single element from a 2D array. This will cause an error.

Single Colon Index(Ch.7.5)

Thus, MATLAB supports a single colon index to access all elements of a row or column. All of the third row can thus accessed as sampleMatrix(3, : ). Likewise, all of column 2 can be accessed as sampleMatrix( :, 2). The following example illustrates:

1,2,3,4,

Tiff

Flattening an Array (Ch.7.6)

Unwinding a 2D array into a column array according to the linear indexing sequence is known as flattening an array into a column. Suppose Records = [ 3.4, 5.6; 118.2, 137.2; 14.0, 19.9 ]. What array is returned by recordsList = Records(:)? [ 3.4; 118.2; 14.0; 5.6; 137.2; 19.9 ] The values are read via linear indexing to produce a column array. This is known as flattening an array into a column.

Linear Indexing (Ch.7.2)

Uses a single index to refer to an array element. The linear index corresponds to the position when columns are appended. So if an array has 3 rows, then the first column's indices will be 1, 2, 3; the second column's indices will be 4, 5, 6; the third column will be 7, 8, 9, and so on. Ex: cityRain = 100, 98, 97 77, 78, 75 56, 58, 61 What value results from cityRain(5)? With the second column appended after the first, element 4 is 98, element 5 is 78, and element 6 is 58.

Single Colon Operator to Replace all Array Elements with a Scalar (Ch.7.6)

When the single colon index appears on the right or left hand side of an assignment, the arrays on each side of the assignment must have identical dimensions. There is one exception: a single colon index may be used to replace all the elements of a 2D array with a single variable when the single variable appears on the right-hand side of an assignment. For example, the statement sampleMatrix(:) = 1 replaces all elements of sampleMatrix with 1.

Logical Operator (Ch.9.3)

When used in the expression for branches and loops (discussed elsewhere) a logical operator treats operands as being true or false, each operates on operands

myArray = [5:1:9] yields... (Ch.4)

[5, 6, 7, 8, 9]

myArray = [50, 60, 70, 80, 90] myArray([3, 4, 5]) yields...

[70, 80, 90] [3, 4, 5] is the indexing array

memory (Ch. 1)

a circuit that can store several 0s and 1s in each of a series of billions addressed locations

Code Block (Ch.9.4)

a construct that directs execution to one list of statements

a == b (Ch.9.2)

a is equal to b

a > b (Ch.9.2)

a is greater than b

a >= b (Ch.9.2)

a is greater than or equal to b

a < b (Ch.9.2)

a is less than b

a <= b (Ch.9.2)

a is less than or equal to b

a ~= b (Ch.9.2)

a is not equal to b

concatenate (Ch.4)

a new array is created by appending a second array's elements of a first array's element; arrayNew = [array1, array2]; can also be used to create a larger array of the same name

floating-point number (Ch.2)

a number of the form a * b^#, MATLAB stores real numbers in this form

complex number (Ch.2)

a numerical value consisting of a real part and an imaginary part

vector (Ch.4)

a one dimensional array

command window (Ch.1)

a place in which a programmer types statements to be executed by the MATLAB interpreter

Branching (Ch.9.4)

a program involves using a construct that directs execution to one list of statements (also referred to as a code block) or another list of statements based on the value of a logical expression that evaluates to either true or false. Logical expressions can include relational operators (such as < or ==) and logical operators (such as &, |,or ~).

operating system [OS] (Ch.1)

a program that allows a user to run other programs and interfaces with the many other peripherals

interpreter (Ch. 1)

a program that directly reads a high-level statement written in the programming language

matrix (Ch.4)

a rectangular array of items in rows and columns

continuation (Ch.2)

a sequence of 3 or more periods "..." at the end of a line which continues a long expression on the next line

script (Ch.3)

a sequence of statements stored in a text file, ends in .m

scalar (Ch.2)

a single number

cache [memory] (Ch.1)

a small amount of RAM on a processor chip, helps with speed

identifier (Ch.2)

a variable name

Add X, #num, Y (Ch.1)

adds the data in memory location X plus the number "num", storing the result in location Y

array (Ch. 4)

an ordered sequence of items of a given data type

& (Ch.9.3)

and is evaluated after not. Thus a & b | c evaluates as (a & b) | c. The expression will always be true if both and and b are true, for example.

arithmetic array operation with a scalar (Ch.4)

applies an arithmetic operation involving a scalar to each element in the array

array1 = [1, 2, 3] array2 = [4, 5, 6] array1 = [array1, array2] (Ch.4)

array1 = [1, 2, 3, 4, 5, 6]

End (Ch.7.7) testMatrix(:, :) = k

assigns all the values in testMatrix to scalar value k.

camel case (Ch. 2)

capitalizing the first letter of each word in a variable name

ceil(x) (Ch.5.2) Ex:2 A parking lot charges $2/hour and they round to the next hour.

ceil rounds each element of x to the nearest integer greater than or equal to the element. Ex: ceil(-7.1) = -7 because -7 is the first integer towards +infinity Ex:2 Reasoning-Rounds to the nearest integer greater than or equal to the element, which is desired in this case.

format compact (Ch.1)

changes the default vertical double spacing to single spacing

format loose (Ch.1)

changes the spacing from single to double

%c (Ch.3)

character

%g (Ch.3)

chooses between either %f or %e, whichever is shorter

clear (Ch.1)

clears all variables from the workspace, so all variables values are lost

clc (Ch.1)

clears the command window

expression (Ch.2)

combination of items like variables, constants, and operators

log10(x) (Ch.3)

common log

double colon operator (Ch.4)

constructs a numeric row array by specifying a starting value, an increment value, and a terminating value, with those values separated by colons; mArray = [firstValue : incrementValue : terminatingValue:];

format string (Ch.3)

contains a literal text, formatting operators, and special characters

linspace(xStart, xStop, numPoints) (Ch.4)

creates a row array of linear spaces points, given a start value, stop value, and the number of desired points

logspace(powerStart, powerStop, numPoints) (Ch.4)

creates a row array with numOfPoints points, logarithmically spaced from 10^powerStart to 10^powerStop

%d (Ch.3)

decimal integer that does not have a fraction

aDiag = diag(vector) (Ch.7.10)

diag(vector) returns a square array with the values in the 1D array argument vector on the diagonal and zeros elsewhere. Ex: diag([2,3,7]) → 2 0 0 0 3 0 0 0 7

workspace (Ch.1)

displays current data being used by the interpreter and variable names

format short (Ch.1)

displays the numbers with 4 digits after the decimal point

Div X, #num, Y (Ch.1)

divides data in location X by "num", sotring the result in location Y

; (Ch.1)

does not print the output of a statements when put at the end

MATLAB by default creates a _____ _____ number. (Ch.2)

double-precision

fixed-point representation (Ch.1)

each umber is displayed with a fixed number of digits after the decimal point

%G (Ch.3)

either %f or %E, whichever is shorter

dot operators (Ch.4)

element-wise multiplication (.*), element-wise division (./), and element-wise exponentiation (.^) requires a a period before the function

exp(x) (Ch.3)

exponential function

aEye = eye(m,n) (Ch.7.10)

eye returns an m by n array aEye with ones on the main diagonal and zeros elsewhere. Ex: eye(2,3) → 1 0 0 0 1 0

fix(x) (Ch.5.2)

fix rounds each element of x to the nearest integer towards zero. Ex: fix(-7.1) = -7 because -7 is the first integer towards 0

floor(x) (Ch.5.2)

floor rounds each element of x to the nearest integer less than or equal to the element. Ex: floor(-7.1) = -8 because -8 is the first integer towards -infinity

atan2 (Ch.3)

four quadrant inverse tangent

sinh (Ch.3)

hyperbolic sine, same for the other trig functions

i/j (Ch.2)

imaginary unit equal to sqrt(-1)

empty array operator [] (Ch. 4)

indicates an array with no elements and element(s) can be deleted using this method

Inf (Ch.2)

infinity

%i (Ch.3)

integer, identical to %d when formatting output

asinh (Ch.3)

inverse hyperbolic sine, same for the other trig functions

atand (Ch.3)

inverse tangent, result in degrees; same for the other trig functions

atan (Ch.3)

inverse tangent, the same for the inverse form of the other trig functions

Logical Variable (Ch.9.1)

is a variable that has a logical data type (class). Logical variables are more typically created as a result of an operation than by explicitly assigning true or false as above. Logical variables in MATLAB are interchangeable with numeric variables,

Dimensions of an Array (Ch.7.9)

is the number of indices needed to select an element. For example, a two-dimensional (2D) array requires two indices, as in sampleArray(3, 5).

realmax (Ch.2)

largest floating-point number, predefined numerical value

vals = [50, 60, 70, 80] lastval = vals(end) (Ch.4)

lastval = 80

vals = [45, 55, 65, 75] lastval = vals([end:-1:1]) (Ch.4)

lastval = [75, 65, 55, 45]

vals = [ 7, 9.1, 4, 3] lastval = vals([end-2:end]) (Ch.4)

lastval = [9.1, 4, 3]

nLargest = length(inArray) (Ch.7.9)

length returns the number of elements along the largest dimension of inArray. Often used to find length of a 1D array.

log(x) (Ch.3)

log to base e

Use logspace function to create the array [100.0, 10.0, 1.0, 0.1, 0.01] (Ch.4)

logspace(2, -2, 5);

Mul X, #num, Y (Ch.1)

multiplies data in location X by "num", sotring the result in location Y

myArray = [70, 80, 90] myArray(6) = 34 (Ch.4)

myArray = 70 80 90 0 0 34

peripherals (Ch.1)

name for I/O devices

nDim = ndims(inArray) (Ch.7.9)

ndims returns the number of array dimensions.

-Inf (Ch.2)

negative infinity

~ (Ch.9.3)

not (negation) is evaluated next. For example, ~ a & b evaluates as (~a) & b.

interpreted languages (Ch.1)

not directly compiled to machine instructions, an interpreter will read the statement written

NaN (Ch.2)

not-a-number

nArrElement = numel(inArray) (Ch.7.9)

numel returns the number of array elements.

variable = input('x'); (Ch.3)

numerical input from a user can be obtained with this function and stored into a variable

aOnes = ones (m,n) (Ch.7.10)

ones creates an m by n array aOnes with all elements equal to one. Ex: ones(2,3) → 1 1 1 1 1 1

size(x) (Ch.4)

outputs the size of each dimension of the function's input array

disp(variable or a word) (Ch.3)

outputs unformatted variables to the command window without outputting the variable's name

element-wise operator (Ch.4)

performs an operation corresponding pair of elements of two 1D arrays, yielding a new array; the number of elements in the 2 arrays must be equal

%f (Ch.3)

prints a floating-point number sing fixed-point notation

\t (Ch.3)

prints a tab

fprintf('x'); (Ch.3)

prints formatted output from a progrm

MATLAB by default creates a _____ variable. (Ch.2)

real

scalar variable (Ch.2)

refers to a variable that stores one number

signed integer (Ch.2)

represents both positive and negative integer values

unsigned integer (Ch.2)

represents only positive integers

compiled language (Ch.1)

requires a program's code to be fully compiled before the program can be execute

End (Ch.7.7) a = testMatrix(:, n)

returns all elements in column n.

End (Ch.7.7) w = testMatrix(n, :)

returns all elements in row n.

End (Ch.7.7) q = testMatrix(:, end)

returns the last column.

End (Ch.7.7) s = testMatrix(end, :)

returns the last row.

End (Ch.7.7) t = testMatrix(n:m, end)

returns the n to m elements in the last column.

round(x) (Ch.5.2) Ex:2 Report the temperature to the nearest integer.

round rounds each element of x to the nearest integer. Ex: round(-7.1) = -7 because -7 is the nearest integer Ex:2 Reasoning-Rounds each element of x to the nearest integer. Desired in this case.

%E (Ch.3)

scientific notation floating-point number with capital E

%e (Ch.3)

scientific notation floating-point number with lowercase e

, (Ch.1)

separates multiple statements, a statement followed by this will have its result printed

format long (Ch.1)

sets the display to show 15 digits after the decimal point

[nRow,nCol] = size(inArray) (Ch.7.9)

size returns the number of rows and number of columns (nRow, nCol) of the array inArray. If only the row dimension is needed, then the programmer should use size(inArray,1). If only the column dimension is needed, then the programmer should use size(inArray,2).

realmin (Ch.2)

smallest floating-point number, predefined numerical value

Describe %-8.2f (Ch.3)

specifies that the floating-point number should be left-aligned (-), using 8 spaces minimum, and with 2 digits to the right of the decimal point

% - fieldWidth.precision (Ch.3)

specifies the items alignment to be left or right, the minimum number of digits/ spaces that will be displayed, and the number of digits to the right of the decimal point to print

%s (Ch.3)

string

Sub X, #num, Y (Ch.1)

subtracts the "num" from the data in location X, storing the result in location Y

% (Ch.3)

supports a single-line comment, the interpreter ignores all text to the right of the sign on the line

tand (Ch.3)

tangent of argument in degrees, the same for the other trig functions in degrees

tan (Ch.3)

tangent, the rest of the trig functions also use the regular abbreviation

Jmp Z (Ch.1)

tells the processor that the next instruction to execute is in memory location Z

Moore's Law (Ch.1)

the doubling of IC capacity roughly every 18 months to make smaller transistors

index (Ch.4)

the integer used to access an individual element in a row array

Concatenation (Ch.7.3)

the operation of joining arrays to form a larger array. Two row arrays ra1 and ra2 can be concatenated into a new larger array using a comma: newArray = [ra1, ra2]. Two column arrays ca1 and ca2 can be concatenated using a semicolon: newArray = [ca1; ca2].

vals(end-1) refers to... (Ch.4)

the second to last array element

non-volatile (Ch.1)

they maintain their contents even when powered off

clock (Ch.1)

ticks at a specific frequency, instructions are executed at a rate governed by the ticks

transpose of an array (Ch.4)

turns rows into columns; colArray = transpose(rowArray) or colArray = rowTemps'

\\ (Ch.3)

two backslash characters print one backslash character

%% (Ch.3)

two percent characters print one percent character

'' (Ch.3)

two single quotation marks print a single quotation mark

Construct arrays whose elements are in descending order (Ch.4)

use a negative increment; myArray = [5: -1: 0]

multi-line comment (Ch.3)

uses %{...%}, any text between these two signs is ignored

vals = linspace (0, 1, 5) (Ch.4)

vals = 0 0.25 0.50 0.75 1.0

vals = [3, 4 ,5, 6] vals(2)= [ ] (Ch.4)

vals = [3 5 6]

Use logspace function to create vals = [1.0, 10.0, 100.0, 1000.0, 10000.0] (Ch.4)

vals = logspace (0, 4, 5);

assignment statement (Ch.2)

variable = #, age = 20

row array (Ch.4)

variable = [element1, element2, element3, . . ., elementN];

column array (Ch.4)

variable = [element1; element2; element3; . . .; elementn];

array element (Ch.4)

what each value in the array is called

How do you increase the size of an array? (Ch.4)

write an element on the outside of the existing range of elements; myArray = [1, 3, 2] myArray (4) = 5 .

x = myArray(3) (Ch.4)

writes the 3rd element of myArray into x

xVec = [10:15] xVec(2:4) = [] (Ch.4)

xVec = 10 11 12 13 14 15

aZero = zeros(m,n) (Ch.7.10)

zeros gives an m by n array aZero with all elements equal to zero. Ex: zeros(2,3) → 0 0 0 0 0 0


Conjuntos de estudio relacionados

Bio 122 Study Guide Chapter 16: The Molecular Basis of Inheritance

View Set

Macroeconomics chapters 1, 2, 23, 24, 25, 26, Chapter 35, Chapter 33, Macroeconomics chapt 28, Chapt 27 Macroeconomics

View Set

ATI Fundamentals Proctored Practice

View Set

EAQ NCLEX, Maternity Chap 28, Maternity and Women's Health Nursing - Newborn, Nur 106- Module G2, Pediatric Growth & Development EAQ, Nursing Sciences EAQ, Theory Communication, Nursing SBU

View Set