Finding x for when y equals a certain value

My current problem is that I have a huge set of data for a pressure rise caused by a train entering the tunnel. I would like to find the values of x whenever the pressure rises crosses a pressure threshold and would like to be able to work out the difference between the pair of x's (should only be one pair)

 采纳的回答

Say x is your x-vector, and I'll let y be your pressure readings, would the following work? I'll make the threshold 2 in this example, but obviously you have to use your value.
y = abs(randn(100,1));
x = 0:99;
index1 = find(y>2,1,'first');
index2 = find(y(index1+1:end)<2,1,'first');
index2 = index2+index1;
x(index2)-x(index1)

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by