嗨我在下面的代碼中有三維矩陣。我試圖將每個「number_panels」和「number_turbines」組合的所有24個元素「n」相加。總和三維矩陣 - Matlab蠻力
我具有低於跨過第三尺寸
不總和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
你是否試圖計算一個3D矩陣的總和? – TJ1 2012-07-14 13:18:57
以及我創建它的方式,我試圖總結「n」維,所以是的,我試圖總結3D矩陣 – user643469 2012-07-14 13:20:02
我希望這可以工作,但它不會:daily_deficit(number_panels + 1,number_turbines + 1)= sum(hourly_deficit(number_panels + 1,number_turbines + 1),3) – user643469 2012-07-14 13:23:11