I used Excel to enter the power calculations on a simulated data set (voltage and current). I later wanted something more responsive to what-ifs and designed for mathematical computation. I stumbled on a MatLab like open source tool cal GNU-Octave. I decided to download and install the tool to enter basic power calculations.
What I like about this tool and like Matlab is the ability to manipulate matrices and vectors. I can set up calculations for my power without resorting to annoying for loops. With my short attention span, I liked this.
Earlier I described the basic math and reduced the following salient equations:
For giggles, I wanted to use Octave to calculate and plot power curves. I know from sampling theory that we need to sample at least at the Nyquist frequency to be able to reconstruct the signal.The reality is we don’t live in an ideal world with perfect filters. More about sampling rate later.
I created functions in Octave to generate a waveform. I can also import a text file with data values and compute the various types of powers as well. I wanted to test a couple of sunny day scenarios to ensure that my calculations were correct. I took two approaches. One I actually defined the function and let Octave integrate it. The other was to sample the function like I would in the software. Both yielded the same results. The table below outlines the expected and actual results.
| Test # | Description | Measurement Point | Expected | Actual | Comment |
|---|---|---|---|---|---|
| 1 | 60 Hz Phase 0, Vm=Im=1 | Vrms | Vm*sqrt(2)=0.707 | 0.707 | pass |
| 1 | 60 Hz Phase 0, Vm=Im=1 | Irms | Im*sqrt(2)=0.707 | 0.707 | pass |
| 1 | 60 Hz Phase 0, Vm=Im=1 | Apparent Power | Vrms*Irms = 0.5 | 0.5 | pass |
| 1 | 60 Hz Phase 0, Vm=Im=1 | Average Power | Apparent Power * cos( 0-0)=.5 | 0.5 | pass |
| 1 | 60 Hz Phase 0, Vm=Im=1 | Reactive Power | apparent power * sin (0-0) = 0.0 | 0.0 | pass |
| 1 | 60 Hz Phase 0, Vm=Im=1 | Power Factor | cos(0-45)=1 | 1.0 | pass |
| 2 | 60 Hz Phase I=45 degrees, Vm=Im=1 | Vrms | Vm*sqrt(2)=0.707 | 0.707 | pass |
| 2 | 60 Hz Phase I=45 degrees, Vm=Im=1 | Irms | Im*sqrt(2)=0.707 | 0.707 | pass |
| 2 | 60 Hz Phase I=45 degrees, Vm=Im=1 | Apparent Power | Vrms*Irms = 0.5 | 0.5 | pass |
| 2 | 60 Hz Phase I=45 degrees, Vm=Im=1 | Average Power | Apparent Power * cos( 0-45)=0.35355 | 0.35355 | pass |
| 2 | 60 Hz Phase I=45 degrees, Vm=Im=1 | Reactive Power | Apparent Power * sin( 0-45)=0.35355 | 0.35355 | pass |
| 2 | 60 Hz Phase I=45 degrees, Vm=Im=1 | Power Factor | cos( 0 - 45 ) = 0.707 | 0.707 | pass |
I also generated an odd current waveform that could occur in speed control via a triac or something and ploted the graph below.

Intuitively one would expect the average power to be half of the sunny day scenario. The other half is reactive power. The following shows the power calculations for varying sampling rates.
| Sampling Rate | Power Calcs |
|---|---|
| 10,000 samples per second | Vrms = 0.70711 Irms = 0.49990 apparentpwr = 0.35348 avaragepwr = 0.24990 reactivePower = 0.25000 pf = 0.70697 pfAngle = 45.011 |
| 1000 samples per second | Vrms = 0.70711 Irms = 0.49900 apparentpwr = 0.35285 avaragepwr = 0.24900 reactivePower = 0.25000 pf = 0.70569 pfAngle = 45.115 |
| 600 samples per second | Vrms = 0.70711 Irms = 0.49833 apparentpwr = 0.35237 avaragepwr = 0.24833 reactivePower = 0.24999 pf = 0.70475 pfAngle = 45.191 |
| 120 samples per second | Vrms = 0.70711 Irms = 0.49160 apparentpwr = 0.34761 avaragepwr = 0.24167 reactivePower = 0.24986 pf = 0.69522 pfAngle = 45.955 |