Info

This question is closed. Reopen it to edit or answer.

Get indices for cells in an array that match a value, refer to the other column of data, put these into a new variable

1 view (last 30 days)
I have m lots of 2 columns of data, length n, stored in a 2 x n x m array.
[x] = 2 x n x m doubles
I plot each data set on a graph, and allow the user to select the data point from n to plot across the m data sets. e.g. value_store = 520
How would I find the index of the data where value_store matches the data in column 1 of the 2 x n x m array, and use that to refer to the point I wish to plot in each series m?
For p = 1:m
% find which cell is equal to the user-selected value
% refer to the other column of data
% put this data into a new variable
end
plot(y-axis_value_at_selected_data_points,m)
where m is the data sets from the original array
Thanks in advance for the help

Answers (1)

the cyclist
the cyclist on 17 Nov 2015
x(:,:,1)==value_store
returns a 2 x n matrix identifying all the locations in the first "slice" (which contains all the "first columns" of your 3-D array) of x that equal value_store.

Community Treasure Hunt

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

Start Hunting!