I have current vs. time, I want to graph total charge vs. time

6 ビュー (過去 30 日間)
Stefan
Stefan 2011 年 11 月 14 日
Hi all,
So I have a dataset of electric current (y) vs. time (t), recorded at 20kHz. The range of t is 4ms. Plot(t,y) shows the expected change in current over time, and trapz(t,y) gives the area under the curve.
I would like to plot charge (Q) vs. time (t). Naturally, trapz(t,y) gives me the total charge that passed through the resistor over 4ms. However, I want to have a smooth, monotonic plot of Q from t=0 to t=4 (if y was constant, than charge at t=2 would be half of charge at t=4).
I imagine this as something like the following:
Q(x) = trapz(x,y) where x represents a number that moves from 0 to t (from 0-4ms).
I can't seem to put this together in a way that MATLAB understands, any ides would be welcome. I need the input to be (t,y), and the output to be a list of data points that match up with t, perhaps (t,q).
Thanks for your ideas! Stefan
  2 件のコメント
Walter Roberson
Walter Roberson 2011 年 11 月 14 日
Are you looking for http://www.mathworks.com/help/techdoc/ref/cumtrapz.html ?
Stefan
Stefan 2011 年 11 月 14 日
Solved! Thanks!

サインインしてコメントする。

採用された回答

Doug Hull
Doug Hull 2011 年 11 月 14 日
Putting Walters answer here so this is no longer classified as "unanswered"

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by