Intergral calculation for data vector
Show older comments
Hello,
I need to calculate the toatal energy of solar system and I have the solar power as 43200x1 double. I tried to use trapz and trapezodial method but I get only NAN as the answer. Can somone please guid me how to solve this problem?
So thankful for your help.
%% Iput data from a system:
B_V=B_V_12*12;
Inv_C_Amp=Inv_C_12_5*12.5;
Sol_C_Amp=Solar_C_12_5*12.5;
Enr_T_MWh=Energy_tot_0_5*0.5;
Enr_K_MWh=Energy_kiosk_0_5*0.5;
Enr_sch_MWh=Energy_school_0_5*0.5;
%% Calculate the rest of needed data by using the input data:
Bat_C=Inv_C_Amp-Sol_C_Amp;
Sol_P_W=Sol_C_Amp.*B_V;
Inv_P_W=Inv_C_Amp.*B_V;
% Efficiency= Total power out/Power into inverter
Eff=((Enr_T_MWh)./(Inv_P_W*1000000))*100;
Sol_Energy = trapz(t,Sol_P_W );
%% store Time duration for winter period where the lower temp in July.
t1=datetime(2018,07,01,2,1,0);
t2=datetime(2018,07,31,2,0,0);
t=t1:minutes(1):t2;
%% Plot the result of the data:
figure(1)
subplot(2,2,1)
plot(t,B_V,'r')
title('Battery voltage');
xlabel('Time');
ylabel('Volt');
subplot(2,2,2)
plot(t,Bat_C,'r')
title('Battery current');
xlabel('Time');
ylabel('A');
subplot(2,2,3)
plot(t,Inv_C_Amp,'b')
title('Inverter current');
xlabel('Time');
ylabel('A');
subplot(2,2,4)
plot(t,Sol_C_Amp,'g')
title('Solar current');
xlabel('Time');
ylabel('A');
%Figures for the plower data
figure(2)
subplot(2,1,1)
plot(t,Sol_P_W,'r')
title('Solar power');
xlabel('Time');
ylabel('Watt');
subplot(2,1,2)
plot(t,Inv_P_W,'b')
title('Inverter power');
xlabel('Time');
ylabel('Watt');
figure(3)
subplot(3,1,1)
plot(t,Enr_T_MWh,'b')
title('Total energy provided');
xlabel('Time');
ylabel('MWh');
subplot(3,1,2)
plot(t,Enr_K_MWh,'r')
title('Energy provided to kiosk');
xlabel('Time');
ylabel('MWh');
subplot(3,1,3)
plot(t,Enr_sch_MWh,'r')
title('Energy provided to school');
xlabel('Time');
ylabel('MWh');
figure(4)
plot(t,Eff,'r')
title('Inverter efficiency');
xlabel('Time');
ylabel('%');
%Energy calculation
%
% Sol_Energy = trapz(Sol_P_W );
% Sol_Energy= cumtrapz(Sol_P_W)
%
3 Comments
Rik
on 8 May 2019
Did you check if your input data contains any NaN values? I would look for any zeros in your divisor. You can use the code below to locate NaN values in a vector.
nan_location=@(x) find(isnan(x))
Abm
on 8 May 2019
Thank you for responding. No, I don’t have any NAN value in the (Sol_P_W) vector.
Erivelton Gualter
on 8 May 2019
Can you share the Sol_P_W data?
Accepted Answer
More Answers (0)
Categories
Find more on Digital Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!