Error Dot indexing is not supported for variables of this type in d.getLinkLenght EPANET Toolkit

2 次查看(过去 30 天)
Hi, I have a problem in my code.
First I call to
start_toolkit;
inpname='Net.inp';
d=epanet(inpname);
....
d.setLinkDiameter(Index_Pipe,D);
I haven't problems calling the functions, until it appears this error. Dot indexing is not supported for variables of this type.
Error in CodeESP (line 220)
d.setLinkDiameter(Index_Pipe,D);

回答(1 个)

Shubham
Shubham 2023-12-18
Hey @Elías,
I understand that you are using EPANET toolkit. You used “epanet” function to create an object for EPANET toolkit interface and tried to access the method “setLinkDiameter” which produced the error: “Dot indexing is not supported.”
Dot indexing is used for accessing the fields in struct or methods in objects. The error regarding dot indexing suggests that the variable ‘d’ is not an object or struct.
You can check if EPANET object is initialized correctly. Ensure that the object creation does not raise any errors. You can also use the “whos” command to check the type of variable:
inpname='Net.inp';
d=epanet(inpname);
whos d
You can also check if the variable was overwritten before accessing the “setLinkDiameter” method. Have a look at the following code snippet:
d = 5;
disp(d);
5
d = struct('Name','Alice','Age',25);
disp(d.Name);
Alice
whos d;
Name Size Bytes Class Attributes d 1x1 354 struct
d=10;
disp(d.Name);
Dot indexing is not supported for variables of this type.
In the above code snippet, the variable 'd' is overwritten and when the field 'Name' is accessed using the variable 'd', it produces same error.
Also have a look at these previous MATLAB Answer cases that might help you:
Hope this helps!!

类别

Help CenterFile Exchange 中查找有关 Weather and Atmospheric Science 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by