Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Plotting energy and power in MATLAB

Status
Not open for further replies.

Sean87

Newbie level 6
Joined
Jan 6, 2012
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Netherlands
Activity points
1,366
Hi all,

Maybe this is a noob question but I just started working with MATLAB and really no big idea on how to use its commands and functions.

I have a AC circuit with following equations:
**broken link removed**
equation.jpg

plotting the voltage, current and power wasn't that hard (I think I wrote the correct code, please tell me if you think it's wrong!):

Code:
%Variables 
t1=20e-3;t2=60e-3;N=1000;f=50; 
t=linspace(t1,t2,N); 
Vmax = 10; %Peak Voltage 
Imax = 2; %Peak Current 
f = 50; %Frequency in Hertz 
omega = 2 * pi * f; 
phi_default = -pi/4; %Constant for phase difference 
 
%Equations 
Vsrc = Vmax * sin(omega * t); %Equation for Voltage 
Isrc = Imax * sin((omega * t) + phi_default); %Equation for Current 
Psrc = Vsrc .* Isrc; %Equation for Power 
 
%Plotting the result 
figure(1); %Window 1 
plot(t,Vsrc, 'b', t, Isrc, 'r', t, Psrc, 'g'); %Plotting Voltage, Current and Power

Now the problem is that I can't figure out a way to plot Energy in matlab. I think Δt (Delta t) should be defined maybe using diff(t) function and total energy should be something like:

YC1uP.jpg


And average power Pavr is calculated by \[\frac{ Wtot}{T}\] Where T is period.

So the question is, how can I plot the total instantaneous energy
R9QpX.jpg
as a function of phase difference in range
fcNOA.jpg
for this I think a for loop should be necessery to calculate for each phase value.

Also I want to plot the average power in the same period.

Thanks in advance for tips and tricks!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top