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
0
10
v = [16 5 9 4 2 11 7 14];
v(3) % Extract the third element (ans = 9)
Thank you!
10
0
3.5
2
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
even_values=array(2:2:end)
Retrieve only second elements of array, from secon with 2 step iteration
increase until end of array.
first_3_values=array(1:3)
Retrieve only first 3 elements of array.
Thank you!
2
0
Are there any code examples left?
New code examples in category Matlab
-
Matlab 2022-03-12 20:25:01 switch matlab
-
Matlab 2022-02-28 23:10:26 scilab trace function
-
Matlab 2022-02-22 08:40:07 matlab tilde
-
Matlab 2022-02-09 18:00:07 matlab preallocate array size
-
Matlab 2022-02-09 17:50:01 plot in log scale matlab
-
Matlab 2022-02-03 10:21:25 zsh corrupt history file
-
Matlab 2022-02-02 23:16:39 octave wait
-
Matlab 2022-02-02 19:17:12 matlab app designer numeric edit field properties
-
Matlab 2022-02-02 17:36:14 matlab zero vector
-
Matlab 2022-02-02 15:45:30 diff(x) matrix matlab