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

1 visualización (últimos 30 días)
AngXuman Xarma
AngXuman Xarma el 29 de Abr. de 2016
Editada: Stephen23 el 29 de Abr. de 2016
Kindly explain me the meaning of X (training(c,1),:)? what is the significance of : in matlab commands?

Respuestas (1)

Stephen23
Stephen23 el 29 de Abr. de 2016
Editada: Stephen23 el 29 de Abr. de 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

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by