How to solve the error for graph?
6 ビュー (過去 30 日間)
古いコメントを表示
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
% Define electricity costs
electricity_cost_AT = 0.261;
electricity_cost_BE = 0.245;
electricity_cost_BG = 0.253;
electricity_cost_CZ = 0.247;
electricity_cost_DE_LU = 0.235;
electricity_cost_DK = 0.215;
electricity_cost_EE = 0.193;
electricity_cost_ES = 0.168;
electricity_cost_FI = 0.154;
electricity_cost_FR = 0.276;
electricity_cost_GR = 0.280;
electricity_cost_HR = 0.272;
electricity_cost_HU = 0.272;
electricity_cost_IE = 0.223;
electricity_cost_IT = 0.312;
electricity_cost_LT = 0.230;
electricity_cost_LV = 0.227;
electricity_cost_NL = 0.242;
electricity_cost_PL = 0.167;
electricity_cost_PT = 0.168;
electricity_cost_RO = 0.265;
electricity_cost_SE = 0.101;
electricity_cost_SI = 0.274;
electricity_cost_SK = 0.265;
% Create a structure for electricity costs
electricity_costs = struct(...
'AT', electricity_cost_AT, ...
'BE', electricity_cost_BE, ...
'BG', electricity_cost_BG, ...
'CZ', electricity_cost_CZ, ...
'DE_LU', electricity_cost_DE_LU, ...
'DK', electricity_cost_DK, ...
'EE', electricity_cost_EE, ...
'ES', electricity_cost_ES, ...
'FI', electricity_cost_FI, ...
'FR', electricity_cost_FR, ...
'GR', electricity_cost_GR, ...
'HR', electricity_cost_HR, ...
'HU', electricity_cost_HU, ...
'IE', electricity_cost_IE, ...
'IT', electricity_cost_IT, ...
'LT', electricity_cost_LT, ...
'LV', electricity_cost_LV, ...
'NL', electricity_cost_NL, ...
'PL', electricity_cost_PL, ...
'PT', electricity_cost_PT, ...
'RO', electricity_cost_RO, ...
'SE', electricity_cost_SE, ...
'SI', electricity_cost_SI, ...
'SK', electricity_cost_SK ...
);
FLH = [0,289,584,1392,2326,3371,4789,5711,6414,6945,7362,7733,8045,8261,8437,8559,8627,8667,8707,8723,8747,8755,8758,8760];
LHV = 33.33; %kWh/kgH2
%SOEC parameters
CAPEX_System_SOEC_mean = 4200; %$/kW
CAPEX_System_SOEC_std = 500;
CAPEX_System_SOEC_values = normrnd(CAPEX_System_SOEC_mean, CAPEX_System_SOEC_std, [num_simulations,1]);
CAPEX_System_SOEC_values(CAPEX_System_SOEC_values < 2800) = 2800;
CAPEX_System_SOEC_values(CAPEX_System_SOEC_values > 5600) = 5600;
%CAPEX_Stack_SOEC_values = 0.5*CAPEX_System_SOEC_values; % 50% of CAPEX system
CAPEX_SOEC_values = CAPEX_System_SOEC_values;
OPEX_SOEC_values = 3; % 3% of CAPEX/a
System_Efficiency_SOEC_mean = 0.775;
System_Efficiency_SOEC_std = 0.05;
System_Efficiency_SOEC_values = normrnd(System_Efficiency_SOEC_mean, System_Efficiency_SOEC_std, [num_simulations,1]);
System_Efficiency_SOEC_values(System_Efficiency_SOEC_values < 0.74) = 0.74;
System_Efficiency_SOEC_values(System_Efficiency_SOEC_values > 0.81) = 0.81;
% Define the cell array of country codes
countries = {'DE', 'SE', 'AT', 'BE', 'BG', 'CZ', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LV', 'NL', 'PL', 'PT', 'RO', 'SI', 'SK'};
% Calculate SOEC LCOH values
term1_S = LHV ./ (System_Efficiency_SOEC_values);
term2_S = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_S = (OPEX_SOEC_values / 100);
term4_S = CAPEX_SOEC_values ./ FLH;
% Initialize an array to store LCOH values for each simulation and country
LCOH_SOEC = zeros(num_simulations, 24);
% Loop through each simulation and calculate LCOH for each country
for sim = 1:num_simulations
for country_idx = 1:24
country_code = countries{country_idx}; % Assuming 'DE', 'SE', 'AT', ...
electricity_cost_country = electricity_costs.(country_code);
% Calculate LCOH for the current simulation and country
LCOH_SOEC(sim, country_idx) = term1_S(sim) * ((term2_S(sim) / ((1 + Discount_Rate_values(sim))^Lifetime - 1) + term3_S) * term4_S(sim) + electricity_cost_country);
end
end
% Average values of LCOH for each country
avg_LCOH_SOEC = mean(LCOH_SOEC);
% Plot LCOH values for each country
figure;
hold on;
% Loop through each country and plot LCOH as a line
for country_idx = 1:24
country_code = countries{country_idx};
plot(FLH, avg_LCOH_SOEC(:, country_idx), '--', 'DisplayName', ['AVG_' country_code], 'LineWidth', 2);
end
hold off;
% Customize the plot
title('LCOH vs FLH Comparison for Each Country');
xlabel('FLH (Full Load Hours)');
ylabel('LCOH (Levelized Cost of Hydrogen)');
legend('Location', 'best');
grid on;
I would like to compare avg_LCOH of each country (24 countries) in one graph.
Unrecognized field name "DE".
Error in S1_SOEC_2020 (line 109)
electricity_cost_country = electricity_costs.(country_code);
How to solve this error and plot the graph?
Please let me know the command.
0 件のコメント
回答 (3 件)
Sam Chak
2024 年 1 月 16 日
There are missing characters. From your code, it should be 'DE_LU'.
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
% Define electricity costs
electricity_cost_AT = 0.261;
electricity_cost_BE = 0.245;
electricity_cost_BG = 0.253;
electricity_cost_CZ = 0.247;
electricity_cost_DE_LU = 0.235;
electricity_cost_DK = 0.215;
electricity_cost_EE = 0.193;
electricity_cost_ES = 0.168;
electricity_cost_FI = 0.154;
electricity_cost_FR = 0.276;
electricity_cost_GR = 0.280;
electricity_cost_HR = 0.272;
electricity_cost_HU = 0.272;
electricity_cost_IE = 0.223;
electricity_cost_IT = 0.312;
electricity_cost_LT = 0.230;
electricity_cost_LV = 0.227;
electricity_cost_NL = 0.242;
electricity_cost_PL = 0.167;
electricity_cost_PT = 0.168;
electricity_cost_RO = 0.265;
electricity_cost_SE = 0.101;
electricity_cost_SI = 0.274;
electricity_cost_SK = 0.265;
% Create a structure for electricity costs
electricity_costs = struct(...
'AT', electricity_cost_AT, ...
'BE', electricity_cost_BE, ...
'BG', electricity_cost_BG, ...
'CZ', electricity_cost_CZ, ...
'DE_LU', electricity_cost_DE_LU, ...
'DK', electricity_cost_DK, ...
'EE', electricity_cost_EE, ...
'ES', electricity_cost_ES, ...
'FI', electricity_cost_FI, ...
'FR', electricity_cost_FR, ...
'GR', electricity_cost_GR, ...
'HR', electricity_cost_HR, ...
'HU', electricity_cost_HU, ...
'IE', electricity_cost_IE, ...
'IT', electricity_cost_IT, ...
'LT', electricity_cost_LT, ...
'LV', electricity_cost_LV, ...
'NL', electricity_cost_NL, ...
'PL', electricity_cost_PL, ...
'PT', electricity_cost_PT, ...
'RO', electricity_cost_RO, ...
'SE', electricity_cost_SE, ...
'SI', electricity_cost_SI, ...
'SK', electricity_cost_SK ...
);
FLH = [0,289,584,1392,2326,3371,4789,5711,6414,6945,7362,7733,8045,8261,8437,8559,8627,8667,8707,8723,8747,8755,8758,8760];
LHV = 33.33; %kWh/kgH2
%SOEC parameters
CAPEX_System_SOEC_mean = 4200; %$/kW
CAPEX_System_SOEC_std = 500;
CAPEX_System_SOEC_values = normrnd(CAPEX_System_SOEC_mean, CAPEX_System_SOEC_std, [num_simulations,1]);
CAPEX_System_SOEC_values(CAPEX_System_SOEC_values < 2800) = 2800;
CAPEX_System_SOEC_values(CAPEX_System_SOEC_values > 5600) = 5600;
%CAPEX_Stack_SOEC_values = 0.5*CAPEX_System_SOEC_values; % 50% of CAPEX system
CAPEX_SOEC_values = CAPEX_System_SOEC_values;
OPEX_SOEC_values = 3; % 3% of CAPEX/a
System_Efficiency_SOEC_mean = 0.775;
System_Efficiency_SOEC_std = 0.05;
System_Efficiency_SOEC_values = normrnd(System_Efficiency_SOEC_mean, System_Efficiency_SOEC_std, [num_simulations,1]);
System_Efficiency_SOEC_values(System_Efficiency_SOEC_values < 0.74) = 0.74;
System_Efficiency_SOEC_values(System_Efficiency_SOEC_values > 0.81) = 0.81;
% Define the cell array of country codes
countries = {'DE_LU', 'SE', 'AT', 'BE', 'BG', 'CZ', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LV', 'NL', 'PL', 'PT', 'RO', 'SI', 'SK'};
%% missing ^^^
% Calculate SOEC LCOH values
term1_S = LHV ./ (System_Efficiency_SOEC_values);
term2_S = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_S = (OPEX_SOEC_values / 100);
term4_S = CAPEX_SOEC_values ./ FLH;
% Initialize an array to store LCOH values for each simulation and country
LCOH_SOEC = zeros(num_simulations, 24);
% Loop through each simulation and calculate LCOH for each country
for sim = 1:num_simulations
for country_idx = 1:24
country_code = countries{country_idx}; % Assuming 'DE', 'SE', 'AT', ...
electricity_cost_country = electricity_costs.(country_code);
% Calculate LCOH for the current simulation and country
LCOH_SOEC(sim, country_idx) = term1_S(sim) * ((term2_S(sim) / ((1 + Discount_Rate_values(sim))^Lifetime - 1) + term3_S) * term4_S(sim) + electricity_cost_country);
end
end
% Average values of LCOH for each country
avg_LCOH_SOEC = mean(LCOH_SOEC);
% Plot LCOH values for each country
figure;
hold on;
% Loop through each country and plot LCOH as a line
for country_idx = 1:24
country_code = countries{country_idx};
plot(FLH, avg_LCOH_SOEC(:, country_idx), '--', 'DisplayName', ['AVG_' country_code], 'LineWidth', 2);
end
hold off;
% Customize the plot
title('LCOH vs FLH Comparison for Each Country');
xlabel('FLH (Full Load Hours)');
ylabel('LCOH (Levelized Cost of Hydrogen)');
legend('Location', 'best');
grid on;
0 件のコメント
Hassaan
2024 年 1 月 16 日
The error you're encountering, "Unrecognized field name 'DE'", suggests that the field 'DE' does not exist in the electricity_costs structure. However, I notice in the code you've provided, 'DE' is not explicitly defined in the electricity_costs structure, but 'DE_LU' is. It's possible that you meant to use 'DE_LU' instead of 'DE' in your countries array.
To fix this error, you should either add 'DE' to your electricity_costs structure or use 'DE_LU' in your countries array, depending on which one correctly represents the data you're working with.
Here's how you can modify the countries array if you intend to use 'DE_LU':
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
% Define electricity costs
electricity_cost_AT = 0.261;
electricity_cost_BE = 0.245;
electricity_cost_BG = 0.253;
electricity_cost_CZ = 0.247;
electricity_cost_DE_LU = 0.235;
electricity_cost_DK = 0.215;
electricity_cost_EE = 0.193;
electricity_cost_ES = 0.168;
electricity_cost_FI = 0.154;
electricity_cost_FR = 0.276;
electricity_cost_GR = 0.280;
electricity_cost_HR = 0.272;
electricity_cost_HU = 0.272;
electricity_cost_IE = 0.223;
electricity_cost_IT = 0.312;
electricity_cost_LT = 0.230;
electricity_cost_LV = 0.227;
electricity_cost_NL = 0.242;
electricity_cost_PL = 0.167;
electricity_cost_PT = 0.168;
electricity_cost_RO = 0.265;
electricity_cost_SE = 0.101;
electricity_cost_SI = 0.274;
electricity_cost_SK = 0.265;
% Create a structure for electricity costs
electricity_costs = struct(...
'AT', electricity_cost_AT, ...
'BE', electricity_cost_BE, ...
'BG', electricity_cost_BG, ...
'CZ', electricity_cost_CZ, ...
'DE_LU', electricity_cost_DE_LU, ...
'DK', electricity_cost_DK, ...
'EE', electricity_cost_EE, ...
'ES', electricity_cost_ES, ...
'FI', electricity_cost_FI, ...
'FR', electricity_cost_FR, ...
'GR', electricity_cost_GR, ...
'HR', electricity_cost_HR, ...
'HU', electricity_cost_HU, ...
'IE', electricity_cost_IE, ...
'IT', electricity_cost_IT, ...
'LT', electricity_cost_LT, ...
'LV', electricity_cost_LV, ...
'NL', electricity_cost_NL, ...
'PL', electricity_cost_PL, ...
'PT', electricity_cost_PT, ...
'RO', electricity_cost_RO, ...
'SE', electricity_cost_SE, ...
'SI', electricity_cost_SI, ...
'SK', electricity_cost_SK ...
);
FLH = [0,289,584,1392,2326,3371,4789,5711,6414,6945,7362,7733,8045,8261,8437,8559,8627,8667,8707,8723,8747,8755,8758,8760];
LHV = 33.33; %kWh/kgH2
%SOEC parameters
CAPEX_System_SOEC_mean = 4200; %$/kW
CAPEX_System_SOEC_std = 500;
CAPEX_System_SOEC_values = normrnd(CAPEX_System_SOEC_mean, CAPEX_System_SOEC_std, [num_simulations,1]);
CAPEX_System_SOEC_values(CAPEX_System_SOEC_values < 2800) = 2800;
CAPEX_System_SOEC_values(CAPEX_System_SOEC_values > 5600) = 5600;
%CAPEX_Stack_SOEC_values = 0.5*CAPEX_System_SOEC_values; % 50% of CAPEX system
CAPEX_SOEC_values = CAPEX_System_SOEC_values;
OPEX_SOEC_values = 3; % 3% of CAPEX/a
System_Efficiency_SOEC_mean = 0.775;
System_Efficiency_SOEC_std = 0.05;
System_Efficiency_SOEC_values = normrnd(System_Efficiency_SOEC_mean, System_Efficiency_SOEC_std, [num_simulations,1]);
System_Efficiency_SOEC_values(System_Efficiency_SOEC_values < 0.74) = 0.74;
System_Efficiency_SOEC_values(System_Efficiency_SOEC_values > 0.81) = 0.81;
% Define the cell array of country codes
countries = {'DE_LU', 'SE', 'AT', 'BE', 'BG', 'CZ', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LV', 'NL', 'PL', 'PT', 'RO', 'SI', 'SK'};
% Calculate SOEC LCOH values
term1_S = LHV ./ (System_Efficiency_SOEC_values);
term2_S = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_S = (OPEX_SOEC_values / 100);
term4_S = CAPEX_SOEC_values ./ FLH;
% Initialize an array to store LCOH values for each simulation and country
LCOH_SOEC = zeros(num_simulations, 24);
% Loop through each simulation and calculate LCOH for each country
for sim = 1:num_simulations
for country_idx = 1:24
country_code = countries{country_idx}; % Assuming 'DE', 'SE', 'AT', ...
electricity_cost_country = electricity_costs.(country_code);
% Calculate LCOH for the current simulation and country
LCOH_SOEC(sim, country_idx) = term1_S(sim) * ((term2_S(sim) / ((1 + Discount_Rate_values(sim))^Lifetime - 1) + term3_S) * term4_S(sim) + electricity_cost_country);
end
end
% Average values of LCOH for each country
avg_LCOH_SOEC = mean(LCOH_SOEC);
% Plot LCOH values for each country
figure;
hold on;
% Loop through each country and plot the average LCOH
for country_idx = 1:length(countries)
country_code = countries{country_idx};
plot(avg_LCOH_SOEC(country_idx), 'o-', 'DisplayName', country_code, 'LineWidth', 2);
end
hold off;
% Customize the plot
title('Average LCOH for Each Country');
xlabel('Country Index');
ylabel('LCOH (Levelized Cost of Hydrogen)');
legend('Location', 'best');
grid on;
In this revised code, each country's average LCOH is plotted as a point on the graph, with the country index on the x-axis and the LCOH on the y-axis. This will give you a comparative view of the LCOH across the 24 countries.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
Feel free to contact me.
Star Strider
2024 年 1 月 16 日
I tweaked your code a bit, however it is still incorrect.
The main problem is that ‘avg_LCOH_SOEC’ should be a (24x24) matrix (24 countries and 24 ‘FLH’ units). Then it would work as you want it to. It is instead a (1x24) vector, and that means the plot is plotting points, not vectors (so I changed it to plot markers). I cannot follow what you are doing, so I leave that to you to solve. (The only reason it plots at all is that the number of countries is the same as the length of ‘FLH’.)
The other problem is that ‘FLH’ has as its first element 0 so:
term4_S = CAPEX_SOEC_values ./ FLH;
and so ‘term4_S’ was infinite. That created a matrix of ‘Inf’ and that is the reason the plot was empty. (I added 1 to ‘FLH’ to solve that problem temporarily. Change that so that it does what you want it to.)
This is my slightly edited version of your posted code. It runs and produces a plot, however it needs help to work as you want it to, and only you can provide that for it.
The edited code —
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
% Define electricity costs
electricity_cost_AT = 0.261;
electricity_cost_BE = 0.245;
electricity_cost_BG = 0.253;
electricity_cost_CZ = 0.247;
electricity_cost_DE_LU = 0.235;
electricity_cost_DK = 0.215;
electricity_cost_EE = 0.193;
electricity_cost_ES = 0.168;
electricity_cost_FI = 0.154;
electricity_cost_FR = 0.276;
electricity_cost_GR = 0.280;
electricity_cost_HR = 0.272;
electricity_cost_HU = 0.272;
electricity_cost_IE = 0.223;
electricity_cost_IT = 0.312;
electricity_cost_LT = 0.230;
electricity_cost_LV = 0.227;
electricity_cost_NL = 0.242;
electricity_cost_PL = 0.167;
electricity_cost_PT = 0.168;
electricity_cost_RO = 0.265;
electricity_cost_SE = 0.101;
electricity_cost_SI = 0.274;
electricity_cost_SK = 0.265;
% Create a structure for electricity costs
electricity_costs = struct(...
'AT', electricity_cost_AT, ...
'BE', electricity_cost_BE, ...
'BG', electricity_cost_BG, ...
'CZ', electricity_cost_CZ, ...
'DE_LU', electricity_cost_DE_LU, ...
'DK', electricity_cost_DK, ...
'EE', electricity_cost_EE, ...
'ES', electricity_cost_ES, ...
'FI', electricity_cost_FI, ...
'FR', electricity_cost_FR, ...
'GR', electricity_cost_GR, ...
'HR', electricity_cost_HR, ...
'HU', electricity_cost_HU, ...
'IE', electricity_cost_IE, ...
'IT', electricity_cost_IT, ...
'LT', electricity_cost_LT, ...
'LV', electricity_cost_LV, ...
'NL', electricity_cost_NL, ...
'PL', electricity_cost_PL, ...
'PT', electricity_cost_PT, ...
'RO', electricity_cost_RO, ...
'SE', electricity_cost_SE, ...
'SI', electricity_cost_SI, ...
'SK', electricity_cost_SK ...
);
FLH = [0,289,584,1392,2326,3371,4789,5711,6414,6945,7362,7733,8045,8261,8437,8559,8627,8667,8707,8723,8747,8755,8758,8760];
LHV = 33.33; %kWh/kgH2
%SOEC parameters
CAPEX_System_SOEC_mean = 4200; %$/kW
CAPEX_System_SOEC_std = 500;
CAPEX_System_SOEC_values = normrnd(CAPEX_System_SOEC_mean, CAPEX_System_SOEC_std, [num_simulations,1]);
CAPEX_System_SOEC_values(CAPEX_System_SOEC_values < 2800) = 2800;
CAPEX_System_SOEC_values(CAPEX_System_SOEC_values > 5600) = 5600;
%CAPEX_Stack_SOEC_values = 0.5*CAPEX_System_SOEC_values; % 50% of CAPEX system
CAPEX_SOEC_values = CAPEX_System_SOEC_values;
OPEX_SOEC_values = 3; % 3% of CAPEX/a
System_Efficiency_SOEC_mean = 0.775;
System_Efficiency_SOEC_std = 0.05;
System_Efficiency_SOEC_values = normrnd(System_Efficiency_SOEC_mean, System_Efficiency_SOEC_std, [num_simulations,1]);
System_Efficiency_SOEC_values(System_Efficiency_SOEC_values < 0.74) = 0.74;
System_Efficiency_SOEC_values(System_Efficiency_SOEC_values > 0.81) = 0.81;
% Define the cell array of country codes
countries = {'DE_LU', 'SE', 'AT', 'BE', 'BG', 'CZ', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LV', 'NL', 'PL', 'PT', 'RO', 'SI', 'SK'};
% Calculate SOEC LCOH values
term1_S = LHV ./ (System_Efficiency_SOEC_values);
term2_S = Discount_Rate_values .* (1 + Discount_Rate_values).^Lifetime;
term3_S = (OPEX_SOEC_values / 100);
FLH = FLH + 1; % <-ADDED
term4_S = CAPEX_SOEC_values ./ FLH;
% Initialize an array to store LCOH values for each simulation and country
LCOH_SOEC = zeros(num_simulations, 24);
% Loop through each simulation and calculate LCOH for each country
for sim = 1:num_simulations
for country_idx = 1:24
country_code = countries{country_idx}; % Assuming 'DE', 'SE', 'AT', ...
electricity_cost_country = electricity_costs.(country_code);
% Calculate LCOH for the current simulation and country
% QCI = [sim term1_S(sim) term2_S(sim) ((1 + Discount_Rate_values(sim))^Lifetime - 1) term3_S term4_S(sim) electricity_cost_country]
LCOH_SOEC(sim, country_idx) = term1_S(sim) .* ((term2_S(sim) ./ ((1 + Discount_Rate_values(sim)).^Lifetime - 1) + term3_S) * term4_S(sim) + electricity_cost_country);
end
end
% Average values of LCOH for each country
SzLCOH_SOEC = size(LCOH_SOEC)
avg_LCOH_SOEC = mean(LCOH_SOEC)
% Plot LCOH values for each country
figure;
hold on;
% Loop through each country and plot LCOH as a line
for country_idx = 1:24
country_code = countries{country_idx};
country_code = strrep(country_code, '_', '\_');
plot(FLH, avg_LCOH_SOEC(:,country_idx), '_', 'DisplayName', ["AVG\_" + string(country_code)], 'LineWidth', 2);
end
hold off;
% Customize the plot
title('LCOH vs FLH Comparison for Each Country');
xlabel('FLH (Full Load Hours)');
ylabel('LCOH (Levelized Cost of Hydrogen)');
legend('Location', 'bestoutside', 'NumColumns',2);
grid on;
.
4 件のコメント
Star Strider
2024 年 1 月 16 日
You need to create the (24 x 24) matrix. First, create a (10000 x 24 x 24) matrix representing (simulations x countries x FLH) or some permutation of that, and then calculate the mean over the dimension that represents the number of simulations to get the necessary matrix for the plot. After that, the plot should be straightforward.
I cannot figure out what you are doing, so I cannot help with that part of it.
参考
カテゴリ
Help Center および File Exchange で Additional Math and Discrete についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!