a (:,:, 3,10,6,1) =
45 119 15.242 21.568 115.843 139.661 16.265
255.978 923.596 78.549 102.645 679.539 833.699 81.573
This is the output of the program. Can something tell me what is a (:,:,
3,10,6,1)
What does 3 , 10, 6, 1 indicate? I am new to matlab. Kindly help
variables in the language used by octave and matlab are, in general, arrays. the syntax you showed is requesting a subset of the array. the colon is shorthand for 'everything in this dimension'. You seem to have a 6-dimensional array. so:
a (:,:, 3,10,6,1)
is asking for all elements in the first two dimensions (usually called rows and columns), for a particular location in all other dimensions. You can think of a 3D array like a rectangular prism, and people sometimes refer to the first three indices as rows, columns, and pages. so (1,2,3) would be the element from the 1st row, 2nd column, and 3rd page. (:,2,3) would be the elements in each row, on the second column on the 3rd page.
e.g., see the following example using a simple 2D array.
octave:3> A = rand(4)
A =
0.137917 0.898255 0.858357 0.120261
0.720924 0.308254 0.172525 0.491915
0.957249 0.222406 0.413234 0.313535
0.993320 0.048086 0.681521 0.824905
octave:4> A(1,4)
ans = 0.12026
octave:5> A(1,:)
ans =
0.13792 0.89825 0.85836 0.12026
octave:6> A(3,:)
ans =
0.95725 0.22241 0.41323 0.31353
octave:7> A(:,:)
ans =
0.137917 0.898255 0.858357 0.120261
0.720924 0.308254 0.172525 0.491915
0.957249 0.222406 0.413234 0.313535
0.993320 0.048086 0.681521 0.824905
: also specifies a range:
octave:8> A(2:3,1)
ans =
0.72092
0.95725
octave:9> A(2:3,2:3)
ans =
0.30825 0.17252
0.22241 0.41323