# How to find the value in one column based on a value of a another column.

15 views (last 30 days)
Joshua Krantz on 24 Aug 2022
Answered: Dyuman Joshi on 24 Aug 2022
Hello,
I have a table with time being the first column and Pressure A, B, and C being columns 2-4. I would like to find a way to display the time it takes for the first instance of Pressure A, B and C (which occur at different times) to show a value greater than .6.
Any help is greatly appreciated, I have just started using matlab and am quite confused.

Dyuman Joshi on 24 Aug 2022
%random data
y=table((1:10)',randi(10,10,1),randi(12,10,1),randi(15,10,1),'VariableNames',{'Time','Pressure_A', 'Pressure_B', 'Pressure_C'})
y = 10×4 table
Time Pressure_A Pressure_B Pressure_C ____ __________ __________ __________ 1 1 7 3 2 3 6 12 3 10 10 6 4 6 8 13 5 4 8 7 6 10 3 13 7 7 1 12 8 2 8 14 9 9 3 5 10 9 4 15
%Logical indexing
%We find the 1st index where Pressure is gt 6
%and get the corresponding %time
tA=y.Time(find(y.Pressure_A>6,1))
tA = 3
%similarly for B and C
tB=y.Time(find(y.Pressure_B>6,1))
tB = 1
tC=y.Time(find(y.Pressure_C>6,1))
tC = 2

### Categories

Find more on Tables in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by