any help me with this error ,((Attempted to access HydrogenProduced(1); index out of bounds because numel(Hydr​ogenProduc​ed)=0. Error in main (line 17) CurrentHydrogenInTank(1) = IniHydrogen + HydrogenProduced(1) - H2_consumption(1); ?

조회 수: 1 (최근 30일)
clear all;
%Csur = load('Csur.csv');
H2_consumption = load('H2_consumption.csv');
Psur = load('Psur.csv');
%%%C_grid = 0.17
IniHydrogen = 9000;
H2_consumption = 0.11*H2_consumption;
H2_consumption =modifyConsumption (IniHydrogen, H2_consumption, Psur);
%H2_consumption = modifyConsumption (IniHydrogen, H2_consumption, Psur);
%H2_consumption = H2_consumption*0.7;
HydrogenProduced = calculateMinCost(H2_consumption,IniHydrogen,Psur');
%plot(x_opt);
CurrentHydrogenInTank = zeros(size(HydrogenProduced,1),1);
(((((CurrentHydrogenInTank(1) = IniHydrogen + HydrogenProduced(1) - H2_consumption(1))))); line 17
for i = 2:size(HydrogenProduced,1)
CurrentHydrogenInTank(i) = CurrentHydrogenInTank(i-1) + HydrogenProduced(i) - H2_consumption(i);
end
%hour = 1:1:24;
day = 1:1:365;
plot(CurrentHydrogenInTank);
title('Amount of hydrogen in tank by day');
xlabel('Hour');
ylabel('Amount of hydrogen in tank');
[daily,totalDailyCost, averageCost, totalElectricityCost] = calculateCost(HydrogenProduced);
figure;
plot(daily);
title('Variable cost by hour')
xlabel('Hours');
ylabel('Cost');
note line 17 between two
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2017년 9월 7일
Abdulla - the error message is telling you that HydrogenProduced is an empty matrix (the number of elements, numel, are zero). You may want to step through your code and see why calculateMinCost is returning this empty matrix.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by