get element of matrix matlab code example
Example 1: matlab matrix index
A = [16 5 9; 4 2 11; 7 14 9]; % Create matrix
A(2,3) % Extract the element in row 2, column 3
ans = 11
A(1:2,2:3) % Extract elements in rows 1 and 2, and columns 2 and 3
ans = 5 9
2 11
Example 2: get elements of array matlab
Indicating indexes between ([]) retrieves corresponding values in Matlab.
array_borders=array([1: end])
As end defines size of the array, retrieve first and last border values of array
Example 3: matlab matrix indexing
v = [16 5 9 4 2 11 7 14];
v(3) % Extract the third element (ans = 9)
Example 4: access element in matrix matlab
e = A(3,2)