Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how can i rectify index position error?

조회 수: 1 (최근 30일)
tobi alabi
tobi alabi 2020년 1월 23일
마감: Sabin 2023년 10월 2일
Hi guys,
Thanks for your support so far, please this part of matlab script (hydrogen storage model) is given me this error:
Index in position 1 exceeds array bounds (must not exceed 1).
Error in mescode2019 (line 264)
mesprob.Constraints.hydeogenstored=selfdchh*Eh2(idxHr2Toend-1,:)+(echh2*(h2ch(idxHr2Toend,:)*dt))-((edchh2(idxHr2Toend,:)*dt)/edh2)==Eh2(idxHr2Toend,:);
%initial time variables for 24hrs
dt=1; % Time step
nHours=numel(LD);
Time=(1:nHours)';
idxHr2Toend=2:nHours;
%battery model
mesprob.Constraints.Batstoredele=selfdchb*Et(idxHr2Toend-1,:)+(echb.*Pbch(idxHr2Toend,:)*dt)-...
((Pbdch(idxHr2Toend,:)*dt)./edchb)==Et(idxHr2Toend,:);
mesprob.Constraints.SOCb=Et(idxHr2Toend(1),:)<=Et(idxHr2Toend(end),:);
mesprob.Constraints.Etout=Et<= NOMb;
%thermal storage model
mesprob.Constraints.thermalstored=(1-qselfdch)*Eq(idxHr2Toend-1,:)+(echq.*(qch(idxHr2Toend,:)*dt))-...
((qdch(idxHr2Toend,:)*dt)./edchq)==Eq(idxHr2Toend,:);
mesprob.Constraints.SOCq=Eq(idxHr2Toend(1),:)<=Eq(idxHr2Toend(end),:);
mesprob.Constraints.Eqout=Eq<= NOMq;
%cold storage model
mesprob.Constraints.coldstored=(1-cselfdch)*Ec(idxHr2Toend-1,:)+(echc.*(cch(idxHr2Toend,:)*dt))...
-((cdch(idxHr2Toend,:)*dt)./edchc)==Ec(idxHr2Toend,:);
mesprob.Constraints.SOCc=Ec(idxHr2Toend(1),:)<=Ec(idxHr2Toend(end),:);
mesprob.Constraints.Ecout=Ec<= NOMc;
%hydrogen storage model
mesprob.Constraints.hydeogenstored=selfdchh*Eh2(idxHr2Toend-1,:)+(echh2*(h2ch(idxHr2Toend,:)*dt))...
-((edchh2(idxHr2Toend,:)*dt)/edh2)==Eh2(idxHr2Toend,:);
mesprob.Constraints.SOCh=Eh2(idxHr2Toend(1),:)<=Eh2(idxHr2Toend(end),:);
mesprob.Constraints.Ehout=Eh2 <= NOMh;
This most confusing part is that, the same procedure is applicable to battery storage, cold storage and heat storage, but those ones are not showing that kind of error, please how can i rectify it?
Thanks
  댓글 수: 8
tobi alabi
tobi alabi 2020년 1월 24일
% Load all the datas
LD=[0.1 0.5 0.4 3 5 3 3.5 0.1 0.1 1 3 2 2.3 2.3 2 2.5 5 6 7 6.5...
4 2.5 2.3 0.1]; % Home Load Data for 24 hrs in kW
%initial time variables for 24hrs
dt=1; % Time step
nHours=numel(LD);
Time=(1:nHours)';
idxHr2Toend=2:nHours;
%hydrogen storage model
selfdchh=0.001; %self-discharging parameters
Eh2=optimvar('Eh2',nHours,1,'LowerBound',0,'UpperBound',20` );
mesprob.Constraints.hydeogenstored=selfdchh*Eh2(idxHr2Toend-1,:)+(echh2*(h2ch(idxHr2Toend,:)*dt))...
-((edchh2(idxHr2Toend,:)*dt)/edh2)==Eh2(idxHr2Toend,:);
mesprob.Constraints.SOCh=Eh2(idxHr2Toend(1),:)<=Eh2(idxHr2Toend(end),:);
mesprob.Constraints.Ehout=Eh2 <= NOMh;
the information are the details concerning the code, if i change idxHr2Toend=2:nHours to 1:nHours, it will display error concerning the matrix agreement
tobi alabi
tobi alabi 2020년 1월 24일
Thank you very much everyone, i've been able to rectify the error

답변 (0개)

이 질문은 마감되었습니다.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by