1/112
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
What are matrices and arrays in MATLAB?
They are the basic building blocks in MATLAB
How are variables defined by default in MATLAB?
Every variable is defined as an array
What dimensions can an array have in MATLAB?
One-dimensional, two-dimensional, or higher
What is a one-dimensional array?
An array with only one row or one column
How can a one-dimensional array be created directly?
By listing elements separated by commas or spaces
How do you create a row vector using commas?
a = [1, 2, 4]
How do you create a row vector using spaces?
b = [4 5 6]
What type of arrays are row vectors?
One-dimensional arrays with one row
How can array size be checked?
Using the whos command
What does whos display?
Variable names, sizes, and data types
How do you create a column vector?
By separating elements with semicolons
Give an example of a column vector.
c = [7; 8; 9]
How can a row vector be converted into a column vector?
Using the transpose operator (')
What does a' do in MATLAB?
Converts a row vector to a column vector and vice versa
How can the colon operator convert vectors?
b(:) converts a row vector into a column vector
What is the colon syntax for creating arrays?
start:step:end
Give an example of colon syntax.
x = 0:2:10
What kind of array does colon syntax create?
An array with evenly spaced elements
Can colon syntax create decreasing arrays?
Yes
Give an example of a decreasing array.
y = 5:-2:0
What limitation does colon syntax have?
It does not explicitly specify the number of elements
What function creates linearly spaced arrays?
linspace
What is the syntax of linspace?
linspace(start, end, number of elements)
What is the default number of elements in linspace?
100
What does linspace distribute?
Elements linearly over an interval
What function creates logarithmically spaced arrays?
logspace
How are elements distributed in logspace?
Logarithmically over an interval
What is a two-dimensional array?
An array with multiple rows and columns
What is another name for a two-dimensional array?
A matrix
How do you directly create a matrix?
By separating rows with semicolons
Give an example of matrix creation.
A = [1 2 0; 4 5 6; 7 8 9]
How can arrays be concatenated vertically?
Using semicolons
What condition is required for vertical concatenation?
Arrays must have the same number of columns
How can arrays be concatenated horizontally?
Using spaces or commas
What does horizontal concatenation produce?
A longer array
What function creates an all-ones matrix?
ones
What does ones(3,2) create?
A 3×2 matrix of ones
What happens if ones has one argument?
A square matrix is created
What function creates an all-zero matrix?
zeros
Give an example of zeros usage.
zeros(4,2)
What function creates an identity matrix?
eye
What does eye(4) create?
A 4×4 identity matrix
Can eye create rectangular matrices?
Yes
Give an example of a rectangular identity matrix.
eye(4,3)
What function generates uniformly distributed random numbers?
rand
What is the range of rand values?
Between 0 and 1
What is the average value of rand?
0.5
How can you change the mean and range of rand?
By scaling and shifting the output
What function generates normally distributed random numbers?
randn
What is the mean of randn by default?
0
What is the standard deviation of randn by default?
1
How can you generate random matrices with a specific mean and standard deviation?
By scaling and shifting rand or randn
What does randn(size(A)) do?
Generates a random matrix with the same size as A
What is array addressing?
Accessing specific elements using indices
How do you access the third element of an array x?
x(3)
How do you access an element using row and column indices?
x(row, column)
What is the row and column structure of a row vector?
One row and multiple columns
What is the structure of a column vector?
Multiple rows and one column
What does the colon operator do in indexing?
Extracts a range of elements
How do you extract elements from index 2 to 5?
x(2:5)
How do you extract elements from an index to the end?
x(3:end)
How do you extract arbitrary elements?
Using an index array
How are submatrices created?
By specifying row and column ranges
How do you extract specific rows from a matrix?
Using row indices with colon for columns
How do you extract a full row?
D(3,:)
How do you extract a full column?
D(:,end)
How can a matrix be copied?
By simple assignment
How do you change a single matrix element?
Assign a new value using indices
How do you replace an entire row?
Assign a vector to that row
How do you delete a row?
Assign an empty array to that row
How do you delete a column?
Assign an empty array to that column
What does the length function return for an array?
The number of elements
What does length return for a matrix?
The largest dimension
What function returns matrix dimensions?
size
What does [r,c] = size(A) return?
Number of rows and columns
What does the max function do on an array?
Returns the maximum value
What does max return on a matrix by default?
Maximum of each column