Meaning of x = X(training(c,1),:);

1 view (last 30 days)
AngXuman Xarma
AngXuman Xarma on 29 Apr 2016
Edited: Stephen23 on 29 Apr 2016
Kindly explain me the meaning of X (training(c,1),:)? what is the significance of : in matlab commands?

Answers (1)

Stephen23
Stephen23 on 29 Apr 2016
Edited: Stephen23 on 29 Apr 2016
Why not use the power of the internet to learn how MATLAB works? I used [an internet search engine] to search for "MATLAB colon" and the very first result was this very informative page:
At the top of the page is written "The colon is one of the most useful operators in MATLAB", and just a few lines down the page I found this example:
A(i,:) is the ith row of A.
which matches your example. After reading that page we learn that the line
X(training(c,1),:)
uses indexing to return the training(c,1)-th rows of the variable X. Alternatively you can think of the colon as meaning "all columns" of X (because it is used as the column index).
Here is a simple example:
>> X = [1,2;3,4] % define a matrix
X =
1 2
3 4
>> X(1,:) % pick the first row and all columns
ans =
1 2

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!