Trapezoidal wave RMS value

I am calculating RMS value of trapezoidal wave.

I found its formula like below:

and at last the RMS value formula:

u = 30degree or pi/6 --> especially pi/6

A = 12

When I calculate RMS value by this formula, I got 2 but by matlab, I got 11.314, when I calculate the RMS value by fourier series, I got 8.48 where did I make mistake ?

Here the codes

inputs = -pi:0.0001:pi;

outputs = zeros(1,length(inputs));
u = pi/6;
A = 12;

for i =1:length(inputs)

if inputs(i) <= u/2-pi && inputs(i)>=-pi
outputs(i) = -2*A*pi/u - 2*A*inputs(i)/u;

elseif inputs(i)>=u/2-pi && inputs(i)<(-u/2)
outputs(i) = -A;

elseif inputs(i)>=(-u/2) && inputs(i)<=(u/2)
outputs(i) = 2*A*(inputs(i))/u;

elseif inputs(i)>(u/2) && inputs(i)<=(pi-u/2)
outputs(i) = A;

elseif inputs(i)>(pi-u/2) && inputs(i)<(pi)
outputs(i) = 2*A*(pi - inputs(i))/u;

end

end

mean(outputs)
rms(outputs)
%axis([-10,10,-4*pi,4*pi]);
plot(inputs,outputs);


• Please edit your question and post the images directly into this forum. It's poor practice to refer other users to an off-site page which may be gone at some point in the future. Apr 15 at 15:47
• Have you tried plotting your "waveform"? Apr 15 at 16:52
• I get $8\cdot\sqrt{2}$, same as MATLAB. Apr 15 at 16:53

The formulas for both the waveform and the RMS calculations have typos. For the waveform's first and last intervals, there is an extra minus in the 2nd terms. The terms should be:

\begin{align} &\dfrac{2A}{u}(-\pi-t)\tag{1} \\ &\dfrac{2A}{u}(\pi-t)\tag{2} \end{align}

Strangely enough, the way they are written in the integrands is fine, but the result is off in the last integration, it should be the same result as in the first integration:

$$\dfrac{A^2u}{12\pi}\tag{3}$$

Now, if you calculate the sum for the RMS:

$$A\sqrt{2\dfrac{u}{12\pi}+2\dfrac{\pi-u}{2\pi}+\dfrac{u}{6\pi}}=A\sqrt{\dfrac{u}{3\pi}+\dfrac{\pi-u}{\pi}}\tag{4}$$

And if you replace $$\u=\pi/6\$$ and $$\A=12\$$:

\begin{align} 12\sqrt{\dfrac{\pi}{6}\dfrac{1}{3\pi}+\dfrac{\pi-\dfrac{\pi}{6}}{\pi}}&=12\sqrt{\dfrac{1}{18}+\dfrac{5\pi}{6}\dfrac{1}{\pi}} \\ &=12\sqrt{\dfrac{1}{18}+\dfrac{5}{6}} \\ &=12\sqrt{\dfrac{16}{18}} \\ &=\dfrac{12}{3}\cdot 2^{\frac{3}{2}} \\ &=\dfrac{3\cdot 2^2}{3}\cdot 2^{\frac{3}{2}} \\ &=2^3\cdot 2^{\frac12} \\ &=8\sqrt{2} \tag{5} \end{align}

Sorry for the lengthy noobish arithmetic, just wanted to be sure it's clear enough how to reach Spehro Pefhany's result.

• I am so glad to see these steps. I fixed the error in my calculations. Thank you so much.
– Piko
Apr 16 at 8:31

where did I make mistake ?

Something is definitely wrong with math formulas. I haven't checked your calculations, but results are very confusing:

1. Why Vrms5 != Vrms1? The wave is symmetric, so they should be equal.

2. How come Vrms5 is negative - in your notation it's the integral of a non-negative function.

3. Why does Vrms approach zero as u approaches zero? Shouldn't Vrms approach A in that case?

Perhaps you should double-check the integrals. They look reasonable and the intent behind them is clear enough, but the result seems wrong.

The formula seems wrong.

You can decide what should be the coorect answer by taking u=0, which gives you a square wave. And for a square wave, the answer is : $$V_{RMS} = A$$ Thus, the value you got with Matlab seems correct.

The ratio between what you got with Matlab and Fourier series is close to $$\\sqrt{2}\$$. Maybe you forgot this coefficient ? Are the coefficient of your Fourier series amplitudes or RMS values of the different harmonics ?

• here what I found regarding fourier series: hizliresim.com/LLD496 hizliresim.com/iLpQMo As you said, I should find Vrms = A when u = 0. I will check my integrals and formulas again.
– Piko
Apr 16 at 8:38