Values from a column selection index vector

Version (1.72 KB) by Eydrian
Returns the actual values chosen of a data from a column index vector


Updated Fri, 14 Jun 2013 14:04:40 +0000

View License

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)

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

the values at the selected column positions

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

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:

Other Classes required:

see also: sub2ind

Cite As

Eydrian (2023). Values from a column selection index vector (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

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