MATLAB Answers

How to extract corresponding values of x-axis based y-axis values.

10 views (last 30 days)
Good day,
Could someone please help me on how to extract corresponding values of x-axis based on y-axis values?
I would like to extract the corresponding values of these elements; 5,6,7,4,5,6,7(values from y-axis) in x-axis.
I only know how to find a corresponding single value not multiple values.

Sign in to comment.

More Answers (1)

Mara on 1 Jul 2020
Edited: Mara on 1 Jul 2020
maybe use ismember:
idx = ismember(y, [5,6,74,5,67])
xvalues = x(idx)
P.S. sorry for the editing, I now read your problem correctly
AUWAL ABUBAKAR on 1 Jul 2020
Thanks, Mara. It works almost percfectly except for the issue Adam mentioned. The approach also matched the last value of y.
Thank you both once again for your help

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!