MATLAB Answers

Fetching x axis Data values and corresponding y data value

14 views (last 30 days)
Darpan Verma
Darpan Verma on 12 Mar 2019
Commented: Darpan Verma on 12 Mar 2019
I have some data in the form
x = [1x72] a matrix which is x axis of the data
y = [1x72] a matrix which is y axis of the data
I am using following code
index = find(x>4 & x<5.1) %to fetch all those x axis data points having values between 4 and 5.1
Which gives me all those columbs numbers having values between 4 and 5.1
But I want the Data i.e. "x" not the columb number. What should I do?
I also want to get the corresponding values of "y" at all those selected x point.
Thanks in advance.
Screen Shot 2019-03-11 at 10.00.30 PM.png

  0 Comments

Sign in to comment.

Accepted Answer

KSSV
KSSV on 12 Mar 2019
To get the y values correspeonding to x:
idx = x >4 & x<5.1 ;
x1 = x(idx) ;
y1 = x(index) ;
% To get others
x2 = x(~idx) ;
y2 = y(~idx) ;

  1 Comment

Darpan Verma
Darpan Verma on 12 Mar 2019
Thanks KSSV you are too good with MATLAB. I appreciate your help.

Sign in to comment.

More Answers (0)

Sign in to answer this question.