How do i calculate the area under curve for 2 curves
1 view (last 30 days)
Show older comments
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)');
0 Comments
Accepted Answer
Star Strider
on 30 Jul 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.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!