필터 지우기
필터 지우기

How do i calculate the area under curve for 2 curves

조회 수: 4 (최근 30일)
rammah nagi
rammah nagi 2019년 7월 30일
답변: Star Strider 2019년 7월 30일
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)');

채택된 답변

Star Strider
Star Strider 2019년 7월 30일
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개)

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by