How do i calculate the area under curve for 2 curves

1 visualización (últimos 30 días)
rammah nagi
rammah nagi el 30 de Jul. de 2019
Respondida: Star Strider el 30 de Jul. de 2019
How do I calculate the area under this curve for both variables? The Jan excel file is also attached.
%%Electrical output
fileName1 = 'Jan.xlsx';
numData1 = xlsread(fileName1);
Apv = 48 * 1.566; % 48=NoPanels 1.566 area of PV per panel
nel=0.238;
syms J
P= Apv*J*nel;
Pout = subs(P,{J},{numData1(2:25,6)'});
%%
hour = (numData1(2:25,4)');
figure (2);
plot(hour,Pout);
Pconsumption = (numData1(2:25,16)');
hold on;
plot(hour,Pconsumption,'r');
hold off
title('Electrical Power Generated vs Electrical Power consumed')
legend('Electrical Power from PV','Power requirement of system');
xlabel('Time of day');
ylabel( 'Power (W)');

Respuesta aceptada

Star Strider
Star Strider el 30 de Jul. de 2019
It depends on the result you want. Note that the last values in your vectors are NaN, so that is going to cause problems in your calculations.
I would instead use:
Pout = Apv*nel*numData1(2:24,6);
hour = (numData1(2:24,4));
Pconsumption = (numData1(2:24,16));
For the integrations, try this:
cintPout = cumtrapz(hour, Pout); % Cumulative Integration
intPout = trapz(hour, Pout); % Complete Integration
cintPconsumption = cumtrapz(hour, Pconsumption); % Cumulative Integration
intPconsumption = trapz(hour, Pconsumption); % Complete Integration
Choose the full integration or the cumulative integration (that you can plot) depending on what you want to do.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by