1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Calculate and plot real and reactive power matlab

  1. Feb 14, 2014 #1
    1. The problem statement, all variables and given/known data
    Write a Matlab function to compute and plot real and reactive power consumed (or
    supplied) by a known impedance (the value of complex impedance should be used as the function’s input) as a function of either current or voltage (use a character: V or I as a second input) for a predefined range of 0-200 V or 0-10 A. Your function must report the impedance value in the plot title. Both, real and reactive powers should be plotted on the same axes. Verify functionality of your module for 300+j100 Ω and 100-j100 Ω impedances. Plot the power both
    vs. voltage and current (total of four separate graphs).

    2. Relevant equations

    3. The attempt at a solution




    This is my code so far this is what I get:

    >> Compute_Power_Real_Reactive(300+100i,1:50:200)
    ??? Error using ==> mtimes
    Inner matrix dimensions must agree.

    Error in ==> Compute_Power_Real_Reactive at 7

    I cannot figure out why this doesn't work
  2. jcsd
  3. Feb 17, 2014 #2


    User Avatar
    Gold Member

    in matlab everything is matrix based. so if you do A/B, that is matrix division of A and B.

    if you do A./B, that is element by element division of A and B.

    so short answer, your code should look like this

  4. Feb 22, 2014 #3
    Thanks I figured out what I was doing wrong turns out I was right on some of it but needs quite a bit more code to do
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted