Calculate and plot real and reactive power matlab

In summary, the conversation was about writing a Matlab function to compute and plot real and reactive power consumed or supplied by a known impedance as a function of current or voltage for a predefined range. The function must also report the impedance value in the plot title and plot both real and reactive powers on the same axes. The functionality was verified for two different impedances. The provided code had an error due to incorrect use of matrix division, which was corrected by using element by element division.
  • #1
DODGEVIPER13
672
0

Homework Statement


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).



Homework Equations





The Attempt at a Solution


function[Real,Reactive]=Compute_Power_Real_Reactive(impedance,V)


I=V/abs(impedance);
theta=atan(imag(impedance)/real(impedance));

P=V*I*cos(theta);
Q=V*I*sin(theta);

disp(P);
disp(Q);
end

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
P=V*I*cos(theta);

I cannot figure out why this doesn't work
 
Physics news on Phys.org
  • #2
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

P=V.*I*cos(theta);
Q=V.*I*sin(theta);
 
  • #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
 

FAQ: Calculate and plot real and reactive power matlab

1. What is the purpose of calculating and plotting real and reactive power in Matlab?

The purpose of calculating and plotting real and reactive power in Matlab is to analyze and visualize the power flow in an electrical system. Real power is the actual power consumed by a load, while reactive power is the power used to maintain the magnetic field in inductive components. Understanding the real and reactive power flow can help in optimizing the power system and identifying potential issues.

2. How do I calculate real and reactive power in Matlab?

To calculate real and reactive power in Matlab, you can use the built-in power calculations functions such as realpower and reactivepower. These functions take in voltage and current data as inputs and output the corresponding real and reactive power values.

3. Can I plot real and reactive power in the same graph in Matlab?

Yes, you can plot real and reactive power in the same graph in Matlab by using the plot function. You can plot real power as a solid line and reactive power as a dashed line to differentiate between the two.

4. How can I interpret a plot of real and reactive power in Matlab?

A plot of real and reactive power in Matlab can provide insights into the power flow in an electrical system. The real power plot will show the actual power consumed by the loads, while the reactive power plot will show the power used to maintain the magnetic field. A high reactive power value can indicate the presence of inductive components, while a low reactive power value can suggest a capacitive load.

5. Is it possible to export the calculated and plotted real and reactive power data from Matlab?

Yes, it is possible to export the calculated and plotted real and reactive power data from Matlab. You can save the data as a text, CSV, or Excel file using the save function. You can also copy and paste the data from the Matlab plot into other applications such as Microsoft Excel for further analysis.

Similar threads

Replies
7
Views
1K
Replies
2
Views
1K
Replies
16
Views
3K
Replies
9
Views
1K
Replies
4
Views
3K
Replies
8
Views
3K
Replies
4
Views
3K
Back
Top