• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/20

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

20 Cards in this Set

  • Front
  • Back
Accessing Cell Arrays
indexing with '( )' gives the container
indexing with '{ }' gives the contents

Ex.
CA = {1 2 4 {3}}
CA(3) ==> [4] %class 'cell'
CA{3} ==> 4 %class 'double'
CA(4) ==> {1x1 cell} %a nested cell(cell within a cell)
CA{4} ==> [3] %class 'cell'
class(obj)
Determines the data type of an object
deal(...)
Distributes cell array results among variables
Accessing structures
getfield(str,<fld>)--Extracts the value of the field <fld>

val = struct(#).field

{stra.data} -- will extract all the values into a cell array
Functions to Test whether an object is a certain class/character
(returns a boolean value)
isa(obj, str) -- Tests for a given data type
ischar(ch) -- Determines whether the given object is of type char
isletter(ch) -- Determines if character is a letter
iscell(...) -- Determines whether the given object is a cell
isfield(str, <fld>)--true if the string is a field in this structure
islogical(...)--Determines whether the given object is of type logical
isnumeric(...)--Determines whether the given object is of type double
isstruct(...) -- Determines whether the given object is a structure
isspace(a) -- Tests for the space character
isnan(B) -- test if obj is NAN(not a number)
How to build a structure
struct(...) -- Constructs a structure from <fieldname><value> pairs of parameters

str = setfield(str,<fld>, <value>) -- Constructs a structure in which the value of the field <fld> has been changed

struct(#).field = value
Functions to Cast
char(...) -- Casts to a character type

double(a) -- Casts to type double
uint8(...) -- Casts to unsigned integer type with 8 bits
int2str(a) -- Converts an integer to its numerical
representation(a string)
num2str(a,n)Converts a number to its numerical
representation with n decimal places
Functions to Display/print commands
disp(...) -- Displays matrix or text
fprintf(...) -- Prints formatted information
var = input(...) -- Prompts the user to enter a value
sscanf(...) -- Formats input conversion
sprintf(...) -- Formats a string result
Functions to Comparing strings
strcmp(s1, s2) -- Compares two strings; returns true if equal
strcmpi(s1, s2) -- Compares two strings without regard to case; returns true if equal
Functions to Manipulate strings
upper('string') -- makes all letters upper case
lower('string') -- makes all letters lower case
for loops: Setting iterations
for var = v -- A code module repeats as many times as there are elements in the vector v

for i = 1:1:value
switch statements
switch var
case value1 %if var = value
this = that
case value 2
this = that
otherwise
this = that
end
Functions to find certain values in an array
find( a>3) -- Computes a vector of the locations of the true values in a logical array
A(A > 12) %gives where A is greater than 12
[v,in] = max(a) Finds the maximum value and its position in a
[v,in] = min(a) Finds the minimum value and its position in a
Functions to preallocate/build arrays
linspace(fr,to,n) -- Defines a linearly spaced vector
rand(r, c) -- Calculates an r _ c array of evenly distributed random numbers in the range 0...1
randn(r, c) -- Calculates an r _ c array of normally
distributed random numbers in the range 0...1
magic(n) -- Generates a magic square
ones(r, c) -- Generates an array filled with the value 1
zeros(r, c) -- Builds an array filled with the value 0
Functions to "round" arrays
ceil(x) -- Rounds x to the nearest integer toward
positive infinity
fix(x) -- Rounds x to the nearest integer toward zero
floor(x) -- Rounds x to the nearest integer toward minus infinity
round(x) Rounds x to the nearest integer
Functions to find the dimensions of an array
size(a) -- Determines the dimensions of an array
length(a) -- Determines the largest dimension of an array
Functions to mathematically manipulate arrays.
mod(vec, #) -- returns the remainder
sum(a) -- Totals the values in a
cross(a, b) -- Vector cross product
mean(a) -- Computes the average of the elements in a
Ways to index vectors
v([1 5 6]) % Extract the first, fifth, and sixth elements
v2 = v([5:8 1:4]) % Extract and swap the halves of v
v(2:end-1) % Extract the second through the next-to-last elements
v([2 3 4]) = [10 15 20] % Replace some elements of v
Ways to index matrices/arrays
A(2:4,1:2)
A(:,end) % Extract last column
logical indexing
A(A > 12) %gives where A is greater than 12
str(isspace(str)) = '_' %replace space with underscore