I would like to know what the meaning of
col2=b1(1:end,lead);
is in MATLAB?
I would like to know what the meaning of
col2=b1(1:end,lead);
is in MATLAB?
This is very basic stuff. We are led to assume that b1
is a 2-dimensional array. The contents of an array are indexed using brackets, so b1(1,1)
will return the top left element of array b1
. The first index in your example, 1:end
is selecting every element in the first dimension (matlab indexes rows first, then columns). The second index, lead
in your example, selects a particular column. We assume that lead
has been allocated previously somewhere in the code.
Thence, b1(1:end,lead)
returns to col2
a 1-dimensional array containing a subarray of b1
. This could be accomplished more elegantly using col2=b1(:,lead);
.