I am trying to plot Voltage, Current and Power of a circuit in one plot in matlab. Here are the equations:



I am not sure how to define the phi in matlab, is it just like -3.14/4 or radians? if so can you tell me how to define it in a matlab script?
Here is the code I wrote for this task:
t = 0: 0.1:100;
pi = 3.14;
Vmax = 10;
Imax = 1;
f = 50;
phi_default = -pi/4;
Vsrc = Vmax * sin((2*pi*f) * t);
Isrc = Imax * sin((2*pi*f) * t + phi_default);
% Psrc = Vsrc * Isrc; %
% plot(t,Vsrc, t, Isrc, t, Psrc); %
% legend('V', 'I', 'P') ;
plot(t,Vsrc, t, Isrc);
legend('V', 'I');
The problem with the commented out lines is that as you may know the power is defined as V * I so when I want to do that I get this error: Inner matrix dimensions must agree. how to fix this?
Thanks!
You want to do element-wise multiplication, not matrix multiplication.