Info
This question is closed. Reopen it to edit or answer.
how can i rectify index position error?
1 view (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!