How to visualize histogram

1 次查看(过去 30 天)
Minhee
Minhee 2023-12-18
评论: the cyclist 2023-12-20
num_simulations = 10000;
%Common parameters
Discount_Rate_min = 0.06; % assume 6-8%
Discount_Rate_max = 0.08;
Discount_Rate_values = unifrnd(Discount_Rate_min, Discount_Rate_max, [num_simulations, 1]);
Lifetime = 20; % years
Electricity_Cost_values = 0.185; %EUR/kWh
FLH = [4000,6000,8000];
LHV = 33.33; %kWh/kgH2
%SOEC 2020 parameters
CAPEX_System_SOEC_mean_2020 = 4200; %$/kW
CAPEX_System_SOEC_std_2020 = 50;
CAPEX_System_SOEC_values_2020 = normrnd(CAPEX_System_SOEC_mean_2020, CAPEX_System_SOEC_std_2020, [num_simulations,1]);
CAPEX_System_SOEC_values_2020(CAPEX_System_SOEC_values_2020 < 2800) = 2800;
CAPEX_System_SOEC_values_2020(CAPEX_System_SOEC_values_2020 > 5600) = 5600;
CAPEX_Stack_SOEC_values_2020 = 0.5*CAPEX_System_SOEC_values_2020; % 50% of CAPEX system
CAPEX_SOEC_values_2020 = (CAPEX_System_SOEC_values_2020 + CAPEX_Stack_SOEC_values_2020);
OPEX_SOEC_values_2020 = 3; % 3% of CAPEX/a
System_Efficiency_SOEC_mean_2020 = 0.775;
System_Efficiency_SOEC_std_2020 = 0.01;
System_Efficiency_SOEC_values_2020 = normrnd(System_Efficiency_SOEC_mean_2020, System_Efficiency_SOEC_std_2020, [num_simulations,1]);
System_Efficiency_SOEC_values_2020(System_Efficiency_SOEC_values_2020 < 0.74) = 0.74;
System_Efficiency_SOEC_values_2020(System_Efficiency_SOEC_values_2020 > 0.81) = 0.81;
%SOEC 2030 parameters
CAPEX_System_SOEC_mean_2030 = 1800; %$/kW
CAPEX_System_SOEC_std_2030 = 50;
CAPEX_System_SOEC_values_2030 = normrnd(CAPEX_System_SOEC_mean_2030, CAPEX_System_SOEC_std_2030, [num_simulations,1]);
CAPEX_System_SOEC_values_2030(CAPEX_System_SOEC_values_2030 < 2800) = 800;
CAPEX_System_SOEC_values_2030(CAPEX_System_SOEC_values_2030 > 5600) = 2800;
CAPEX_Stack_SOEC_values_2030 = 0.5*CAPEX_System_SOEC_values_2030; % 50% of CAPEX system
CAPEX_SOEC_values_2030 = (CAPEX_System_SOEC_values_2030 + CAPEX_Stack_SOEC_values_2030);
OPEX_SOEC_values_2030 = 3; % 3% of CAPEX/a
System_Efficiency_SOEC_mean_2030 = 0.805;
System_Efficiency_SOEC_std_2030 = 0.01;
System_Efficiency_SOEC_values_2030 = normrnd(System_Efficiency_SOEC_mean_2030, System_Efficiency_SOEC_std_2030, [num_simulations,1]);
System_Efficiency_SOEC_values_2030(System_Efficiency_SOEC_values_2030 < 0.77) = 0.77;
System_Efficiency_SOEC_values_2030(System_Efficiency_SOEC_values_2030 > 0.84) = 0.84;
%PEM 2020 parameters
CAPEX_System_PEM_mean_2020 = 1450; %$/kW
CAPEX_System_PEM_std_2020 = 50;
CAPEX_System_PEM_values_2020 = normrnd(CAPEX_System_PEM_mean_2020, CAPEX_System_PEM_std_2020, [num_simulations,1]);
CAPEX_System_PEM_values_2020(CAPEX_System_PEM_values_2020 < 1100) = 1100;
CAPEX_System_PEM_values_2020(CAPEX_System_PEM_values_2020 > 1800) = 1800;
CAPEX_Stack_PEM_values_2020 = 0.35*CAPEX_System_PEM_values_2020; % 35% of CAPEX system
CAPEX_PEM_values_2020 = (CAPEX_System_PEM_values_2020 + CAPEX_Stack_PEM_values_2020);
OPEX_PEM_values_2020 = 3;
System_Efficiency_PEM_mean_2020 = 0.58;
System_Efficiency_PEM_std_2020 = 0.01;
System_Efficiency_PEM_values_2020 = normrnd(System_Efficiency_PEM_mean_2020, System_Efficiency_PEM_std_2020, [num_simulations,1]);
System_Efficiency_PEM_values_2020(System_Efficiency_PEM_values_2020 < 0.56) = 0.56;
System_Efficiency_PEM_values_2020(System_Efficiency_PEM_values_2020 > 0.6) = 0.6;
%PEM 2030 parameters
CAPEX_System_PEM_mean_2030 = 1075; %$/kW
CAPEX_System_PEM_std_2030 = 50;
CAPEX_System_PEM_values_2030 = normrnd(CAPEX_System_PEM_mean_2030, CAPEX_System_PEM_std_2030, [num_simulations,1]);
CAPEX_System_PEM_values_2030(CAPEX_System_PEM_values_2030 < 650) = 650;
CAPEX_System_PEM_values_2030(CAPEX_System_PEM_values_2030 > 1500) = 1500;
CAPEX_Stack_PEM_values_2030 = 0.35*CAPEX_System_PEM_values_2030; % 35% of CAPEX system
CAPEX_PEM_values_2030 = (CAPEX_System_PEM_values_2030 + CAPEX_Stack_PEM_values_2030);
OPEX_PEM_values_2030 = 3;
System_Efficiency_PEM_mean_2030 = 0.655;
System_Efficiency_PEM_std_2030 = 0.01;
System_Efficiency_PEM_values_2030 = normrnd(System_Efficiency_PEM_mean_2030, System_Efficiency_PEM_std_2030, [num_simulations,1]);
System_Efficiency_PEM_values_2030(System_Efficiency_PEM_values_2030 < 0.63) = 0.63;
System_Efficiency_PEM_values_2030(System_Efficiency_PEM_values_2030 > 0.68) = 0.68;
%AEC 2020 parameters
CAPEX_System_AEC_mean_2020 = 950; % $/kW
CAPEX_System_AEC_std_2020 = 50;
CAPEX_System_AEC_values_2020 = normrnd(CAPEX_System_AEC_mean_2020, CAPEX_System_AEC_std_2020, [num_simulations,1]);
CAPEX_System_AEC_values_2020(CAPEX_System_AEC_values_2020 < 500) = 500;
CAPEX_System_AEC_values_2020(CAPEX_System_AEC_values_2020 > 1400) = 1400;
CAPEX_Stack_AEC_values_2020 = 0.35*CAPEX_System_AEC_values_2020; % 35% of CAPEX system
CAPEX_AEC_values_2020 = (CAPEX_System_AEC_values_2020 + CAPEX_Stack_AEC_values_2020);
OPEX_AEC_values_2020 = 3;
System_Efficiency_AEC_mean_2020 = 0.665;
System_Efficiency_AEC_std_2020 = 0.01;
System_Efficiency_AEC_values_2020 = normrnd(System_Efficiency_AEC_mean_2020, System_Efficiency_AEC_std_2020, [num_simulations,1]);
System_Efficiency_AEC_values_2020(System_Efficiency_AEC_values_2020 < 0.63) = 0.63;
System_Efficiency_AEC_values_2020(System_Efficiency_AEC_values_2020 > 0.7) = 0.7;
%AEC 2030 parameters
CAPEX_System_AEC_mean_2030 = 625; % $/kW
CAPEX_System_AEC_std_2030 = 50;
CAPEX_System_AEC_values_2030 = normrnd(CAPEX_System_AEC_mean_2030, CAPEX_System_AEC_std_2030, [num_simulations,1]);
CAPEX_System_AEC_values_2030(CAPEX_System_AEC_values_2030 < 400) = 400;
CAPEX_System_AEC_values_2030(CAPEX_System_AEC_values_2030 > 850) = 850;
CAPEX_Stack_AEC_values_2030 = 0.35*CAPEX_System_AEC_values_2030; % 35% of CAPEX system
CAPEX_AEC_values_2030 = (CAPEX_System_AEC_values_2030 + CAPEX_Stack_AEC_values_2030);
OPEX_AEC_values_2030 = 3;
System_Efficiency_AEC_mean_2030 = 0.68;
System_Efficiency_AEC_std_2030 = 0.01;
System_Efficiency_AEC_values_2030 = normrnd(System_Efficiency_AEC_mean_2030, System_Efficiency_AEC_std_2030, [num_simulations,1]);
System_Efficiency_AEC_values_2030(System_Efficiency_AEC_values_2030 < 0.65) = 0.65;
System_Efficiency_AEC_values_2030(System_Efficiency_AEC_values_2030 > 0.71) = 0.71;
% Calculate 2020 SOEC LCOH values
term1_S_2020 = LHV ./ (System_Efficiency_SOEC_values_2020);
term2_S_2020 = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_S_2020 = (OPEX_SOEC_values_2020 / 100);
term4_S_2020 = CAPEX_SOEC_values_2020 ./ FLH;
LCOH_SOEC_2020 = term1_S_2020 .* ((term2_S_2020 ./ ((1 + Discount_Rate_values).^Lifetime - 1) + term3_S_2020) .* term4_S_2020 + Electricity_Cost_values);
% Calculate 2020 PEM LCOH values
term1_P_2020 = LHV ./ (System_Efficiency_PEM_values_2020);
term2_P_2020 = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_P_2020 = (OPEX_PEM_values_2020 / 100);
term4_P_2020 = CAPEX_PEM_values_2020 ./ FLH;
LCOH_PEM_2020 = term1_P_2020 .* ((term2_P_2020 ./ ((1 + Discount_Rate_values).^Lifetime - 1) + term3_P_2020) .* term4_P_2020 + Electricity_Cost_values);
% Calculate 2020 AEC LCOH values
term1_A_2020 = LHV ./ (System_Efficiency_AEC_values_2020);
term2_A_2020 = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_A_2020 = (OPEX_AEC_values_2020 / 100);
term4_A_2020 = CAPEX_AEC_values_2020 ./ FLH;
LCOH_AEC_2020 = term1_A_2020 .* ((term2_A_2020 ./ ((1 + Discount_Rate_values).^Lifetime - 1) + term3_A_2020) .* term4_A_2020 + Electricity_Cost_values);
% Calculate 2030 SOEC LCOH values
term1_S_2030 = LHV ./ (System_Efficiency_SOEC_values_2030);
term2_S_2030 = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_S_2030 = (OPEX_SOEC_values_2030 / 100);
term4_S_2030 = CAPEX_SOEC_values_2030 ./ FLH;
LCOH_SOEC_2030 = term1_S_2030 .* ((term2_S_2030 ./ ((1 + Discount_Rate_values).^Lifetime - 1) + term3_S_2030) .* term4_S_2030 + Electricity_Cost_values);
% Calculate 2030 PEM LCOH values
term1_P_2030 = LHV ./ (System_Efficiency_PEM_values_2030);
term2_P_2030 = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_P_2030 = (OPEX_PEM_values_2030 / 100);
term4_P_2030 = CAPEX_PEM_values_2030 ./ FLH;
LCOH_PEM_2030 = term1_P_2030 .* ((term2_P_2030 ./ ((1 + Discount_Rate_values).^Lifetime - 1) + term3_P_2030) .* term4_P_2030 + Electricity_Cost_values);
% Calculate 2030 AEC LCOH values
term1_A_2030 = LHV ./ (System_Efficiency_AEC_values_2030);
term2_A_2030 = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_A_2030 = (OPEX_AEC_values_2030 / 100);
term4_A_2030 = CAPEX_AEC_values_2030 ./ FLH;
LCOH_AEC_2030 = term1_A_2030 .* ((term2_A_2030 ./ ((1 + Discount_Rate_values).^Lifetime - 1) + term3_A_2030) .* term4_A_2030 + Electricity_Cost_values);
Using the code data, I would like to compare LCOH of six items with histogram.
Image is like the picture.
What is command for it?
  3 个评论
Minhee
Minhee 2023-12-19
I have continuous values.
But can you let me know a bar command as well?
the cyclist
the cyclist 2023-12-20
The link the bar function is in my answer, and it has many examples.

请先登录,再进行评论。

回答(2 个)

the cyclist
the cyclist 2023-12-18
编辑:the cyclist 2023-12-18
You can use the bar function to create it from your data. The link has several examples.

Catalytic
Catalytic 2023-12-18
You can use the histogram command with hold to superimpose them.

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by