# How to find value of average current

I have next code

a = 1;
T = 25;
Subscript[I, 1] = If[t < T, a*t, 2*a*T - a*t];
Plot[Subscript[I, 1], {t, 0, 2 T}, AxesLabel -> {t, I1}] I need to find average current on some interval, for this I do next

t1 = 1;
t2 = 5;
f = 1;
b = Table[If[i <= T, a*i, 2*a*T - a*t], {i, t1, t2, f}]
Subscript[I1, average] = Total[b]/Length[b]


It calculates average current correctly only to 25 value, after that all values are not correct. This error occurs because i don't include 25 value in false condition. How can I fix it? And How can I to get result in List form?

Plot[TriangleWave[x/100], {x, 0, 50}]

Integrate[TriangleWave[x/100], {x, 0, 50}]/50

• You need to divide by the base width of 50 to get there average of 1/2 Nov 29, 2016 at 1:54

Using your code (in case you need to use Table):

a = 1;
T = 25;
i1[t_, T_, a_] = Piecewise[{{a*t, t < T}}, 2*a*T - a*t];
t1 = 1;
t2 = 5;
i1avg = {(Mean@Table[i1[t, T, a], {t, t1, Min[t2, T]}] Max[0, (Min[t2, T] - t1)] +
Mean@Table[i1[t, T, a], {t, Max[t1, T], t2}] Max[0, (t2 - Max[t1, T])])
/(t2 - t1)
}

• does this not give the same inaccurate result as the OP method? If you want to sum discrete values you should use the trapezoidal rule. Nov 29, 2016 at 12:56
• @george2079 Good catch! Didn't look at the underlying. Fixed the answer. Nov 29, 2016 at 14:27