嗨,我在下面的代码中有 3 维矩阵。我试图对每个“number_panels”和“number_turbines”组合的“n”的所有 24 个元素求和。
我在下面的内容并没有在第三维度上求和
对于 number_panels = 0:5
for number_turbines = 0:2
for n = 1:24 % number of hours per day
hourly_deficit(number_panels + 1, number_turbines + 1, n) = Demand(n) -...
(PV_supply(n)*number_panels) - (WT_supply(n)*number_turbines);
if hourly_deficit(number_panels + 1, number_turbines + 1, n)< 0
hourly_deficit(number_panels + 1, number_turbines + 1, n) = 0;
end
daily_deficit(number_panels + 1, number_turbines + 1) = sum(sum(sum(hourly_deficit(:,:,:))))
hourly_total_RES(number_panels + 1, number_turbines + 1, n) = PV_supply(n)*number_panels + WT_supply(n)*number_turbines;
if hourly_total_RES(number_panels + 1, number_turbines + 1, n) < Demand(n),
renewables_penetration(number_panels + 1, number_turbines + 1, n) = (hourly_total_RES(number_panels + 1, number_turbines + 1, n)) / Demand(n); % ratio of renewable energy supply to demand
else
renewables_penetration(number_panels + 1, number_turbines + 1, n) = 1 ;
end
peak_deficit(number_panels + 1, number_turbines + 1,n) = max(hourly_deficit(number_panels + 1, number_turbines + 1,n));
end