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

1 回表示 (過去 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 Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by