필터 지우기
필터 지우기

find time at the midpoint of data

조회 수: 1 (최근 30일)
Charlie Elverson
Charlie Elverson 2015년 5월 5일
댓글: Star Strider 2015년 5월 5일
I have data for which I need to find the time at which the midpoint has been reached. I have a vector of flow rates and a vector of times corresponding to those flow measurements. I was about to code it by hand, when I found the trapz() function to do the numeric integration and give the total discharge. I also need the time at which 50% of the discharge occurred. Is there a function which would give this? I'm aware of how to code it manually, I just want to know if a function already exists to do this.

채택된 답변

Star Strider
Star Strider 2015년 5월 5일
The cumtrapz function will give you a progressive integration of your data, in this instance of flow rates as a function of time.
For example:
Int_Flow = cumtrapz(time, flow_rate);
  댓글 수: 2
Charlie Elverson
Charlie Elverson 2015년 5월 5일
Thanks, but that doesn't quite do what I need (although it'll be very useful if I have to do this by hand). The midpoint falls somewhere between two data points, so I want a function that will interpolate between data points to find where 50% discharge occurs.
Star Strider
Star Strider 2015년 5월 5일
Use the interp1 function to find the time.
Int_Flow = cumtrapz(time, flow_rate);
Flow50 = interp1(Int_Flow, time, Int_Flow(end)/2);
This will give you the time at which the 50% discharge occurs (if I understand your question correctly). The 50% discharge is of course Int_Flow(end)/2.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by