Iteration in 'for loop' returns errors where there aren't errors. How to find the error or skip that iteration?

1 visualización (últimos 30 días)
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 comentarios
Matt J
Matt J el 7 de Jul. de 2021
Editada: Matt J el 7 de Jul. de 2021
Obviously d is not what you intend it to be. It should be a simple matter to stop the code at the offending line and inspect what d actually is at the command line.
Ethan Pillay
Ethan Pillay el 8 de Jul. de 2021
I have run the iteration again a few times. 'd' is not the problem. I was merely stating what d was for reference.
I tried a second attempt without changing the code, out of curiosity, and it stopped at iteration 1305 with the same error.
I have made no changes to code and run it a third time. The third run worked until iteration 2800 before showing the same error.
There seems to be no consistency when the error will be displayed making it hard for me to locate the actual error.
Keep in mind that the 2800 iterations took three and a half hours to run. is there a limit in MATLAB?
Any assistance would be greately appreciated.

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 9 de Jul. de 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
ans = 5
d = 5;
d.A
Dot indexing is not supported for variables of this type.
  1 comentario
Ethan Pillay
Ethan Pillay el 11 de Jul. de 2021
Hi
I only have one variable using the letter 'd' to avoid this issue.
I have implemented a try-catch statement for the for loop and that seems to work.
Thanks

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by