Filter löschen
Filter löschen

solving the problem with the error message 'Dot indexing is not supported for variables of this type.'

55 Ansichten (letzte 30 Tage)
Hey guys, i am a begginer in MATLAB and I am already having difficulties in solving an error in the function for importing and exporting SVG files ( https://de.mathworks.com/matlabcentral/fileexchange/66554-svg-import-export ).... The problem is that I tried it with diferent svg files. With the file 'building.svg' the function worked with out any problem, but it doesn't work with my own file e.g. 'drawing.svg'. It would be nice, if someone help me solve this error...
and here is the error code:
>> example
Dot indexing is not supported for variables of this type.
Error in loadSVG (line 43)
image.x=str2num(char(item.getAttribute('x')));
Error in example (line 1)
svg=loadSVG('drawing.svg');
thanks for ur time...

Akzeptierte Antwort

Guillaume
Guillaume am 7 Dez. 2018
Bearbeitet: Guillaume am 7 Dez. 2018
The error stems from a major bug in the code. length(imagesXml) is wrong, it's always going to return 1 regardless of the number of image tags in the file. The actual count is imagesXml.getLength. So the lines
svg.images=cell(1,length(imagesXml));
for k=0:length(imagesXml)-1
should be replaced by
svg.images=cell(1,imagesXml.getLength);
for k=0:imagesXml.getLength - 1
In effect, because of the bug the code assumes there's always one and only one image tag in the file regardless of the actual count. Since your file does not have an image tag it errors when it tries to get the x attribute of that image. item is empty and dot indexing is not valid for empty arrays.
Strangely enough the code uses the correct getLength syntax in the following loop which iterates over the layers, so it's not like the authors werent' aware of the issue.
  8 Kommentare
kevin harianto
kevin harianto am 6 Apr. 2022
Bearbeitet: Stephen23 am 6 Apr. 2022
I am also wondering why dot indexing is wrong for my code:
Dot indexing is not supported for variables of this type.
Error in (line 166)
image = ptcloud.Location;
Error in (line 121)
I = helperPointCloudToImage(pointCloud);
EDIT: copyright code removed.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by