Arrays1

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/112

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

113 Terms

1
New cards

What are matrices and arrays in MATLAB?

They are the basic building blocks in MATLAB

2
New cards

How are variables defined by default in MATLAB?

Every variable is defined as an array

3
New cards

What dimensions can an array have in MATLAB?

One-dimensional, two-dimensional, or higher

4
New cards
5
New cards

What is a one-dimensional array?

An array with only one row or one column

6
New cards

How can a one-dimensional array be created directly?

By listing elements separated by commas or spaces

7
New cards

How do you create a row vector using commas?

a = [1, 2, 4]

8
New cards

How do you create a row vector using spaces?

b = [4 5 6]

9
New cards

What type of arrays are row vectors?

One-dimensional arrays with one row

10
New cards
11
New cards

How can array size be checked?

Using the whos command

12
New cards

What does whos display?

Variable names, sizes, and data types

13
New cards
14
New cards

How do you create a column vector?

By separating elements with semicolons

15
New cards

Give an example of a column vector.

c = [7; 8; 9]

16
New cards
17
New cards

How can a row vector be converted into a column vector?

Using the transpose operator (')

18
New cards

What does a' do in MATLAB?

Converts a row vector to a column vector and vice versa

19
New cards

How can the colon operator convert vectors?

b(:) converts a row vector into a column vector

20
New cards
21
New cards

What is the colon syntax for creating arrays?

start:step:end

22
New cards

Give an example of colon syntax.

x = 0:2:10

23
New cards

What kind of array does colon syntax create?

An array with evenly spaced elements

24
New cards

Can colon syntax create decreasing arrays?

Yes

25
New cards

Give an example of a decreasing array.

y = 5:-2:0

26
New cards
27
New cards

What limitation does colon syntax have?

It does not explicitly specify the number of elements

28
New cards

What function creates linearly spaced arrays?

linspace

29
New cards

What is the syntax of linspace?

linspace(start, end, number of elements)

30
New cards

What is the default number of elements in linspace?

100

31
New cards

What does linspace distribute?

Elements linearly over an interval

32
New cards
33
New cards

What function creates logarithmically spaced arrays?

logspace

34
New cards

How are elements distributed in logspace?

Logarithmically over an interval

35
New cards
36
New cards

What is a two-dimensional array?

An array with multiple rows and columns

37
New cards

What is another name for a two-dimensional array?

A matrix

38
New cards
39
New cards

How do you directly create a matrix?

By separating rows with semicolons

40
New cards

Give an example of matrix creation.

A = [1 2 0; 4 5 6; 7 8 9]

41
New cards
42
New cards

How can arrays be concatenated vertically?

Using semicolons

43
New cards

What condition is required for vertical concatenation?

Arrays must have the same number of columns

44
New cards

How can arrays be concatenated horizontally?

Using spaces or commas

45
New cards

What does horizontal concatenation produce?

A longer array

46
New cards
47
New cards

What function creates an all-ones matrix?

ones

48
New cards

What does ones(3,2) create?

A 3×2 matrix of ones

49
New cards

What happens if ones has one argument?

A square matrix is created

50
New cards
51
New cards

What function creates an all-zero matrix?

zeros

52
New cards

Give an example of zeros usage.

zeros(4,2)

53
New cards
54
New cards

What function creates an identity matrix?

eye

55
New cards

What does eye(4) create?

A 4×4 identity matrix

56
New cards

Can eye create rectangular matrices?

Yes

57
New cards

Give an example of a rectangular identity matrix.

eye(4,3)

58
New cards
59
New cards

What function generates uniformly distributed random numbers?

rand

60
New cards

What is the range of rand values?

Between 0 and 1

61
New cards

What is the average value of rand?

0.5

62
New cards
63
New cards

How can you change the mean and range of rand?

By scaling and shifting the output

64
New cards

What function generates normally distributed random numbers?

randn

65
New cards

What is the mean of randn by default?

0

66
New cards

What is the standard deviation of randn by default?

1

67
New cards
68
New cards

How can you generate random matrices with a specific mean and standard deviation?

By scaling and shifting rand or randn

69
New cards

What does randn(size(A)) do?

Generates a random matrix with the same size as A

70
New cards
71
New cards

What is array addressing?

Accessing specific elements using indices

72
New cards

How do you access the third element of an array x?

x(3)

73
New cards

How do you access an element using row and column indices?

x(row, column)

74
New cards
75
New cards

What is the row and column structure of a row vector?

One row and multiple columns

76
New cards

What is the structure of a column vector?

Multiple rows and one column

77
New cards
78
New cards

What does the colon operator do in indexing?

Extracts a range of elements

79
New cards

How do you extract elements from index 2 to 5?

x(2:5)

80
New cards

How do you extract elements from an index to the end?

x(3:end)

81
New cards

How do you extract arbitrary elements?

Using an index array

82
New cards
83
New cards

How are submatrices created?

By specifying row and column ranges

84
New cards

How do you extract specific rows from a matrix?

Using row indices with colon for columns

85
New cards

How do you extract a full row?

D(3,:)

86
New cards

How do you extract a full column?

D(:,end)

87
New cards
88
New cards

How can a matrix be copied?

By simple assignment

89
New cards

How do you change a single matrix element?

Assign a new value using indices

90
New cards

How do you replace an entire row?

Assign a vector to that row

91
New cards

How do you delete a row?

Assign an empty array to that row

92
New cards

How do you delete a column?

Assign an empty array to that column

93
New cards
94
New cards

What does the length function return for an array?

The number of elements

95
New cards

What does length return for a matrix?

The largest dimension

96
New cards

What function returns matrix dimensions?

size

97
New cards

What does [r,c] = size(A) return?

Number of rows and columns

98
New cards
99
New cards

What does the max function do on an array?

Returns the maximum value

100
New cards

What does max return on a matrix by default?

Maximum of each column

Explore top flashcards

October exam
Updated 465d ago
flashcards Flashcards (32)
10/6
Updated 218d ago
flashcards Flashcards (62)
PSCH 262 Final Exam
Updated 634d ago
flashcards Flashcards (110)
WWII
Updated 4d ago
flashcards Flashcards (35)
October exam
Updated 465d ago
flashcards Flashcards (32)
10/6
Updated 218d ago
flashcards Flashcards (62)
PSCH 262 Final Exam
Updated 634d ago
flashcards Flashcards (110)
WWII
Updated 4d ago
flashcards Flashcards (35)