How to take values from a data corresponding to specific value

1 view (last 30 days)
I have a 400:2 txt. data. A value corresponding to 0.3 is 1.5373. How can I call the value of 1.5373 from the txt. data by putting 0.3 in the command board?
Please,anybody help me.

Accepted Answer

KSSV
KSSV on 8 Jun 2020
Read about interp1. You can use interpolation and get it.
Also you can use logical indexing. But I prefer interp1. Let A be your 400*2 data.
x = A(:,1) ; y = A(:,2) ;
% Using interp1
xi = 0.3 ;
yi = intepr1(x,y,xi)
% using indices
xi = 0.3 ;
idx = find(abs(x-xi)<10^-3);
yi = x(idx) ;

More Answers (0)

Community Treasure Hunt

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

Start Hunting!