Summary of MATLAB Onramp
Summary of MATLAB Onramp
Basic syntax
Example Description
The left-side (x) is the variable name containing the value on the right-side
(pi).
Desktop management
Functi
Example Description
on
Array types
Example Description
4 scalar
[3 5] row vector
[1;3] column
vector
[3 4 5;6 7 matrix
8]
Evenly-spaced vectors
Example Description
1:4 Create a vector from 1 to 4, spaced by 1, using the colon (:) operator.
linspace(1,10 Create a vector with 5 elements. The values are evenly spaced from 1 to
,5) 10.
Creating matrices
Example Description
Indexing
Example Description
Array operations
Example Description
[1 1; 1 1]*[2 2;2
Perform matrix multiplication.
2]
ans =
4 4
4 4
[1 1; 1 1].*[2 2;2
Perform element-wise
2]
multiplication.
ans =
2 2
2 2
Multiple outputs
Example Description
Documentation
Example Description
Plotting
Example Description
Using tables
Example Description
Logicals
Example Description
[5 10 15] > Compare a vector to the value 12.
12
x(x==999) = Replace all values in x that are equal to 999 with the value
1 1.
Programming
Example Description
if x > 0.5
If x is greater than 0.5, set the value of y to 3.
y = 3
else
y = 4
end Otherwise, set the value of y to 4.
for c =
The loop counter (c) progresses through the
1:3
values 1:3 (1, 2, and 3).
disp(c)
end