how can i rectify index position error?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
Walter Roberson
2020년 1월 23일
As outsiders, we do not know the size of any of those variables.
tobi alabi
2020년 1월 23일
Walter Roberson
2020년 1월 23일
You try to access multiple rows of several different variables. Scalars only have one row.
tobi alabi
2020년 1월 24일
KALYAN ACHARJYA
2020년 1월 24일
Hello Tobi,
Without getting the details of data and variabes, I cant say that "this parameter" exceed the its array length. But you can easily find it by exmine the sizes of variables from the error line. May be you are trying to access some variables, which doesnot have that enough length/size.
Walter Roberson
2020년 1월 24일
As I scan the code it looks to me as if it could only work if LD had exactly one element, and the result it would produce would be empty. If LD is 2 or more elements then the code would try to access row 2 of a number of variables that you have told us are scalars.
tobi alabi
2020년 1월 24일
tobi alabi
2020년 1월 24일
답변 (0개)
이 질문은 마감되었습니다.
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!