The equal sign is not a question
In MATLAB, x = 5 means “calculate the right side, then put the result into the box named x.”
Lesson 2 treats scalars, vectors, and matrices as one family, then learns how to create, locate, calculate, slice, and change them step by step.
A name lets MATLAB find the same value or array again later.
In MATLAB, x = 5 means “calculate the right side, then put the result into the box named x.”
A variable is created by its first assignment, and it can later change from one number into a vector or matrix.
score, Score, and SCORE are three different names.
The only difference is how many rows and columns it has. MATLAB always says rows first, then columns.
An array with one cell, such as 6.
A list of numbers with only one row or only one column.
A number table with several rows and columns.
Text inside quotes, such as 'Hello'.
You can list every number directly, or give MATLAB a start, step, and finish.
[0 1 2 3 4 5]Best when there are only a few irregular values.
start:step:finishBest for a fixed step size.
linspace(start,finish,n)Best when you know how many points you want, not the step size.
Both create n points, but they use different meanings of “evenly spaced.”
Each cell is located by (row, column), and MATLAB counts from 1.
M(2,3)21.3First find row 2, then move along that row to column 3.
It appends everything displayed afterward to a text file until you type diary off.
>>
The file is empty.
Parentheses and powers come first, multiplication and division next, and addition and subtraction last; equal levels go left to right.
c = 2 + 3^2 + 1/(1+2)2 + 3^2 + 1/3* follows matrix algebra; .* multiplies cells in matching positions.
2×5 + 1×7 = 17A 1×3 row vector becomes a 3×1 column vector after transposition.
A semicolon stacks downward, while a space or comma joins to the right; dimensions must match along the seam.
G(:,1) takes every row from column 1; G(2,:) takes every column from row 2.
Assigning to an index changes that cell; assigning beyond the current length extends the array and fills gaps with zeros.
Every skill follows one core idea: a variable stores an array, and an array is organized by rows, columns, and indices.
Loops, logical vectors, functions, graphics, and differential equations will all build on the array thinking from this lesson.