Shared Flashcard Set

Details

Test 1
Functions and indexing for CS 1371 test one
35
Computer Science
Undergraduate 1
02/06/2011

Additional Computer Science Flashcards

 


 

Cards

Term
Function Header
Definition
function [out1 out2] = myFunc(in1, in2)
Term
(Vector) Direct Entry
Definition
vec = [4 2 5 2 3]
Term
(Vector) Colon Operator
Definition
start:step:finish
vec = 3:3
Term
Array of Zeros
Definition
zeros(row, column)
Term
Array of Ones
Definition
ones(rows, columns)
Term
(Vector) Evenly spaced numbers from start to stop.
Definition
linspace(start#, stop#, step_size)
USE COMMAS
Term
Concatenate Arrays Vertically
Definition
cat(1, arr1, arr2)
Term
Concatenate Arrays Horizontally.
Definition
cat(2, arr1, arr2)
Term
(Vector Indexing) Copy Values to new position.
Definition
vec ([A B]) = vec([a b])
A becomes a
B becomes b
Term
(Array and Vector) Row indexing
Definition
vec/arr([start:stop:end, 1])
calls those positions
Term
(Array and Vector) Column Indexing
Definition
vec/arr([1, start:stop:end])
calls those positions
Term
(Array and Vector) Reverse Index.
Definition
vec/arr(end:-1:1, :)
Term
Logical Index (greater and less than)
Definition
> <
Term
Logical Index (greater and less than)
Definition
> <
Term
Logical Index (greater and less than or equal to)
Definition
<= and >=
Term
Logical Index (equal to and not equal to)
Definition
== and ~=
Term
Logical Index (exchange 1s and 0s)
Definition
~var
'~' switches the 1s and 0s of a logical array
Term
Logical Index (exchange 1s and 0s)
Definition
~var
'~' switches the 1s and 0s of a logical array
Term
Logical Index (something is true and something else is true)
Definition
logical statement & other logical statement
& combines two statements
Term
Logical Index (something is true or something else is true)
Definition
logical statement | other logical statement
| combines two statements (either/or)
Term
Linearize an Array
Definition
arr(:)
Takes MxN matrix and makes [M*N, 1] vector following standard positions of the array.
Term
Find minimum values
Definition
min(index, 1) = minimum of selected columns
min(index, 2) = minimum of selected rows
min(min(index, 1)) = absolute minimum of selected rows
Term
Find maximum values
Definition
max(index, 1) = maximum of selected columns
max(index, 2) = maximum of selected rows
max(max(index, 1)) = absolute maximum of selected rows
Term
Find sum of values
Definition
sum(index, 1) = sum of selected columns
sum(index, 2) = sum of selected rows
sum(sum(index, 1)) = absolute sum of selected rows
Term
Find mean of values
Definition
mean(index, 1) = mean of selected columns
mean(index, 2) = mean of selected rows
mean(mean(index, 1)) = absolute mean of selected rows
Term
Create String
Definition
str = 'abcd...' OR
char([ 97 98 99]) OR
num2str(vec)
Term
Create numbers from string
Definition
double('str') OR
'str' .* 1 OR
str2num(str1)
Term
(Vector) Find length
Definition
Length(vec)
Term
Find size of array
Definition

[row col] = size(array)

Never use length for arrays

Term
How to tell if 2 strings are identical
Definition
strcmp(str1, str2) = case sensitive
strcmpi(str1, str2) = case insensitive
Term
Find short string in a longer string
Definition
findstr(str1, str2)
matlab will find shorter string in the longer one order doesn't matter.
It returns the position number of the first letter of each occurrence.
Term
Find series of letters in a string
Definition
strfind(str1, letters)
matlab will find letters in the first entry order.
It returns the position number of the first letter of each occurrence.
Term
strtok
Definition
[token, remain] = strtok(str1, 'delimiter')
token = will return first word
remain = will return the rest of the string
Term
How to create variable string array with optional inputs
Definition
sprintf('str', in1, in2...)
%d means class:double
%s means class:char
Term
How to discover whether type is char or double
Definition
class(input)
Supporting users have an ad free experience!