-7

I would like to know what the meaning of

col2=b1(1:end,lead);

is in MATLAB?

IKavanagh
  • 6,089
  • 11
  • 42
  • 47
  • 2
    Check [Matrix Indexing in Matlab](http://de.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html). – Nemesis Jul 16 '15 at 07:25

1 Answers1

0

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);.

srthompers
  • 169
  • 8