Values from a column selection index vector

版本 1.2.0.0 (1.7 KB) 作者: Eydrian
Returns the actual values chosen of a data from a column index vector
183.0 次下载
更新时间 2013/6/14

查看许可证

selection2values Returns the actual chosen elements of a data from a
vector that indicates the chosen column. Therefor max(selectedElements) <=
max(size(Data)) && min(selectedElements) >= 1

Syntax: chosenValues = selection2values(Data, selectedElements)

Inputs:
Data: is the data where a selction was made on.
selectedElements: is a vector pointing to the column selected

Outputs:
the values at the selected column positions

Example:
DATA = [1, 2, 3, 4; 4, 5, 6, 7];
selectedElements = [1; 3];
values = selection2values(DATA, selectedElements); % returns [1; 6]

or
DATA = randn(500, 4); % data was given
selectedElements = randi(3, 500, 1); % selection was made
values = selection2values(DATA, selectedElements); % the actual values
that are wanted!
Other m-files required:
nothing

Other Classes required:
nothing

see also: sub2ind

引用格式

Eydrian (2024). Values from a column selection index vector (https://www.mathworks.com/matlabcentral/fileexchange/42220-values-from-a-column-selection-index-vector), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2013a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Matrix Indexing 的更多信息
标签 添加标签

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.2.0.0

Updated the return, return before was only indices of the matrix, instead of returning the actual values, fixed!

1.0.0.0