How to find values in a table?

Poseidon · Nov 7, 2023 · 2.2K views
Question
Hi, I have a question, lets say I have a table like this   In matlab I want to find/call a value in column 3 corresponding to say 100 in first column. Not only that, but I also want to use values not in the table (say for 95 in the first column) using linear interpolation. I want to be able to do this using any of the columns. How can I achieve this in MATLAB? Please help.  
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 28, 2026
%let your table be named T

column_with_key = 1;
column_to_examine = 3;

value_to_lookfor = 100;
value_to_extrapolate = 95;

mask = T.(column_with_key) == value_to_lookfor;
wanted_value1 = T.(column_to_examine)(mask)
wanted_value2 = interp1(T.(column_with_key), T.(column_to_examine), value_to_extrapolate)

In practice it is usually shorter than this, such as just

wanted_value = interp1(T.var1, T.var3, 95)

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!