Matlab

Cell array vs struct arrays, a good link https://cs.slu.edu/~ferry/courses/csci1060/notes/165_cells_structures.html

19 flashcards · Programming Languages · by lakesare

  1. [varargin] What does varargin stand for?

    Variable argument in

  2. [varargin] How to access the 2nd argument?

    varargin{2}

  3. Name 2 ways to call this method.

    ordinaryMethod(obj, arg1) obj.ordinaryMethod(arg1)

  4. What does nargin stand for?

    Number of arguments in

  5. What does strcmp stand for?

    String compare tf = strcmp(s1, s2) compares s1 and s2 and returns 1 ( true ) if the two are identical and 0 ( false ) otherwise.

  6. What does sscanf stand for?

    String scan format Parses a string according to a format, => a matrix. A = sscanf(string, format) reads data from the MATLAB string variable s, converts it according to the specified format string, and returns it in matrix A.

  7. What does strcat stand for?

    String concatenate. s = strcat(s1,...,sN) horizontally concatenates the text in its input arguments. Each input argument can be a character array, a cell array of character vectors, or a string array.

  8. What's filesep?

    "/" In order to make this path, we start by using the function "userpath," which returns the name of the default MATLAB folder that we previously put the ts_exper1 folder into. Each new folder name afterwards represents going to a subfolder within the starting folder, and "filesep" acts as the separator characters between subfolders. We use filesep to make sure that every type of device can properly read the path, as different operating systems have different file separation characters. In Wind…

  9. [Data Types] What are arguments to struct(_______________________)? Structure array

    struct(name_1, value_1, ..., name_2, value_2)

  10. [Data Types] Visually imagine: structure array VS cell array.

    structure array - hash cell array - 2d matrix

  11. [Data Types] Name 2 ways to access an entry in a cell array.

    hi(1, 1) //=> { 'cat' } hi{1, 1} //=> 'cat' There are two ways to refer to the elements of a cell array. Enclose indices in smooth parentheses, (), to refer to sets of cells--for example, to define a subset of the array. Enclose indices in curly braces, {}, to refer to the text, numbers, or other data within individual cells.

  12. [Data Types] Visually imagine: cell array VS matrix.

    cell array - { contains anything } (commas are not necessary!)matrix - [ contains homogeneous datatypes ] Cell array may contain any arbitrary type of element in each cell; while a matrix requires the types of its elements to be homogeneous i.e. of the same type.

  13. What does : mean in hi(:, 3)?

    : means "everything" ("all rows"). When you use a colon as a subscript in an indexing expression, such as A(:, n), it acts as shorthand to include all subscripts in a particular array dimension.

  14. What does A(:) do?

    A(:) reshapes all elements of A into a single column vector. This has no effect if A is already a column vector.

  15. [Data Types] What's { 'analog_in', 'digital_in', 'digital_out', 'event', 'time' } object in Matlab?

    Cell array

  16. What does numel stand for?

    Number of elements n = numel(A) returns the number of elements, n, in array A, equivalent to prod(size(A)).

  17. What do ... mean in Matlab?

    Continue to the next line. The three dots '...' tell Matlab that the code on a given line continues on the next line.

  18. What does cat stand for?

    Concatenate (along the dimension dim). C = cat(dim, A, B) concatenates B to the end of A along dimension dim when A and B have compatible sizes (the lengths of the dimensions match except for the operating dimension dim).

  19. Visually imagine repmat(A, 2, 3).

    Repeat matrix. B = repmat(A,r1,...,rN) specifies a list of scalars, r1,..,rN, that describes how copies of A are arranged in each dimension.