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

2 次查看(过去 30 天)
AngXuman Xarma
AngXuman Xarma 2016-4-29
编辑: Stephen23 2016-4-29
Kindly explain me the meaning of X (training(c,1),:)? what is the significance of : in matlab commands?

回答(1 个)

Stephen23
Stephen23 2016-4-29
编辑:Stephen23 2016-4-29
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

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by