Iteration in 'for loop' returns errors where there aren't errors. How to find the error or skip that iteration?
1 view (last 30 days)
Show older comments
Hi all
Some background: I have created a code that goes through every pipe in a water distribution network and checks the viability of implementing a pressure regulating valve. The code places a valve in every pipe, then removes the valve and moves on the the next pipe. This is done using a for loop. Each iteration represents one pipe in the network being tested.
The networks are fairly large, currently 3120 iterations. The code does the exact same thing for every iteration.
My problem is after 762 iterations, MATLAB gives an error stating: "Dot indexing is not supported for variables of this type". I don't understand why MATLAB is returning the error message, as the line of code that has the error is the first line in the for loop.
When I run the code starting just before, and at, the problematic iteration, the code works fine.
The line of code where the error occurs:
'd' is the variable assigned to opening my program and my specific water distribution network. All functions in the toolkit start with 'd.'
N is the number of pipes.
for i = 1:N
hyd_res = d.getComputedTimeSeries; %This is the line of code that gives the error.
end
Any assistance as to why MATLAB would do this would be really helpful.
I am using a Toolkit - EPANET-MATLAB Toolkit.
Thank you
2 Comments
Answers (1)
Cris LaPierre
on 9 Jul 2021
This error suggests that, at some point, your code is overwriting your variable d with one of its own making. When this happens, the next time you try to reference your original d, you will get this error.
Now I don't think you have written this into your code. I suspect somewhere something is not behaving correctly. You can run desktop MATLAB for days, so I don't think that is the issue. I see you've asked the developer of the toolkit the same question so hopefully they can help.
Have you tried using a different name for your variable than d? I don't know that that will fix it, but it's a simple solution to try out.
d.A = 5;
d.A
d = 5;
d.A
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!