This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Select rows of a sample

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


stats::selectRow(s, c, x, <Not>)
stats::selectRow(s, [c1, c2, …], [x1, x2, …], <Not>)


stats::selectRow(s, ...) selects rows of the sample s having specific entries in specific places.

stats::selectRow(s, c, x) returns a sample consisting of all rows in s, which contain the data element x at the position c.

stats::selectRow(s, [c1, c2, …], [x1, x2, …] ) returns a sample consisting of all rows in s, which contain the data element x1 at the position c1 and x2 at the position c2 etc. There must be as many positions c1, c2, … as data elements x1, x2, …


Example 1

We create a sample with two columns:

stats::sample([[a, 5], [c, 1], [a, 2], [b, 3]])
a  5
c  1
a  2
b  3

We select all rows with a as their first entry:

stats::selectRow(%, 1, a)
a  5
a  2

Example 2

We create a sample containing income and costs in the years 1997 and 1998:

stats::sample([[123, "costs", "97"], [442, "income", "98"],
               [11, "costs", "98"], [623, "income", "97"]])
123  "costs"   "97"
442  "income"  "98"
 11  "costs"   "98"
623  "income"  "97"

We select the row which has "income" in the second and "97" in the third column:

stats::selectRow(%, [2, 3], ["income", "97"])
623  "income"  "97"

We select the remaining rows:

stats::selectRow(%2, [2, 3], ["income", "97"], Not)
123  "costs"   "97"
442  "income"  "98"
 11  "costs"   "98"



A sample of domain type stats::sample.

c, c1, c2, …

Integers representing column indices of the sample s.

x, x1, x2, …

Arithmetical expressions.



Causes stats::selectRow to select those rows which do not have the specified entries.

Return Values

Sample of domain type stats::sample.

See Also

MuPAD Functions

Was this topic helpful?