how to resolve the 'dot indexing not supported for this type of variable' error when creating GUIs with GUIDE?
Show older comments
I am writing a code where I hit a pushbutton, it shows me a error saying "Dot indexing is not supported for variables of this type". And this error is for the line 268-- set(handles.edit6,'string',fullname); fullname is basically the filepath and filename combined together.
Any kind of help will be appreciated. Thank you.
20 Comments
Hanna Aharon
on 17 May 2018
I got the same error. Might it have something to do with the version I'm using? (R2018a)
Marwan Albanna
on 29 May 2018
Edited: Marwan Albanna
on 29 May 2018
it is 100% blamed on the version because I have the same error while never occurred previously when I run the GUI hundreds of times on 2017b version. Another reason to go to NI products and stop embarrassing ourselves with this!
Guillaume
on 29 May 2018
By far, the most likely reason for this type of error is a bug in your code. A change of version may make the bug more evident but the bug was already there and probably would have occured at some point. In any case, without any actual code to look at, we can only conjecture.
Using that as an excuse to switch to a different product is, in my opinion, very foolish. Being very familiar with both products, they have completely different strengths and weaknesses. In terms of reliability, my experience is that matlab wins hands down.
Andy Hess
on 31 May 2018
Code from 2015 ran fine and gives this error on 2018 matlab so it is 100% something changed in matlab. That's OK it's very common but let's just not deny facts here.
@Andy, I'm not sure what your point is. Yes, bugs are introduced in new versions (and old ones are fixed). There is nothing unique to matlab here.
On the topic at hand, the error "Dot indexing is not supported for variables of this type" thrown from set(handles.edit6,'string',fullname) is clearly due to the fact that the handles variable is not of a type that support dot indexing. handles is normally a structure and nothing has changed in matlab in that regard. Here it clearly is not and the most likely reason is a bug in a callback where it does not write the handle properly. That buggy callback would be the OP own code. What may have changed with the version of matlab is the order in which the callbacks are executed, thus triggering a bug that was laying dormant.
But again, without any actual code to look at, we can only conjecture. So until some code is posted that demonstrates the problem, I don't see any point in continuing this discussion.
Muhammad Adil Raja
on 20 Jun 2018
I also experienced the same error for a struct that I created using the 'struct' function and then passing it to another function that assigns values to its fields.
Note that MATLAB R2015b changed the behavior when assigning fields to non-structure variables: previously this was allowed (with a warning) and the variable was implicitly converted to a structure, whereas from R2015b+ this throws an error:
The solution is to ensure that the object that should be a structure really is a structure.
Image Analyst
on 1 Jul 2018
Edited: Image Analyst
on 1 Jul 2018
Tell us the exact steps to do to reproduce the error. Because when I ran it with a .wav file, this line of code ran fine:
set(handles.edit6,'string',fullname);
mohanish
on 1 Jul 2018
Edited: Image Analyst
on 1 Jul 2018
Image Analyst
on 1 Jul 2018
I'm using R2018a. There is no listbox of audio files on your GUI, and even worse, there is not even a browse button on your GUI. How are your users supposed to indicate the audio file? How are you browsing to find the wave file? Plus, I do not even see a "back" button
Walter Roberson
on 1 Jul 2018
We are also missing multiply1.fig and SRS01_GUI_MAINPAGE.fig and possibly functions referenced by them.
mohanish
on 1 Jul 2018
mohanish
on 1 Jul 2018
Sameer Gadekar
on 29 Nov 2018
Hey all I am using 2018a same error. But when i run gui through editor it works fine. and when i try to run from figure then error comes
Martin Grden
on 1 Oct 2020
if you try in the CreateFcn of one GUI element to set a value of another GUI element, why it will not work? Maybe, because the other GUI element has not yet ben created. Go to Callback
Walter Roberson
on 1 Oct 2020
The handles structure is not initialized until after all CreateFcn of the saved figure have run.
The order of CreateFcn being run is not well defined for nested objects. For example if you have an axes object within a figure object, then is the CreateFcn for the figure run immediately before the axes is created, or are the CreateFcn run in a "depth-first" strategy, or are all of the objects being loaded created first and then all of the CreateFcn are run? This is not documented.
But we can say for sure that the handles structure is not created at the time the figure is loaded. The handles structure is created afterwards by the GUIDE initialization code. The handles structure is not part of the MATLAB graphics object structure: it is a convenience layer that has been added-on by GUIDE.
Loku Bhanu Teja R
on 2 Nov 2022
function Detection_lines_width()
image=imread('Vegetables.png');
A= rgb2gray(image);
rotA =imrotate(A,0,'crop');
figure;
xy=[];
for l=1:length(lines)
if eq(lines(l).point1(1),lines(l).point2(1))
dist=abs(lines(l).point1(2)-lines(l).point2(2));
else
dist=abs(lines(l).point1(l)-lines(l).point(1));
end
if dist>len
xy=[xy,lines(l)];
end
end
for k=1:length(xy)-1
if eq(xy(k).point1(1),xy(k+1).point1(1)) || eq(xy(k).point2(1),xy(k+1).point2(1))
if(xy(k).point1(2)<xy(k+1).point1(2))
rect=[xy(k).point1(1) xy(k).point1(2) abs(xy(k).point1(1)-xy(k).point2(1)) abs(xy(k).point1(2)-xy(k+1).point1(2)) ];
else
rect=[xy(k+1).point1(1) xy(k+1).point1(2) abs(xy(k).point1(1)-xy(k).point2(1)) abs(xy(k).point1(2)-xy(k+1).point1(2)) ];
end
elseif eq(xy(k).point1(2),xy(k+1).point1(2)) || eq(xy(k).point2(2),xy(k+1).point2(2))
if xy(k).point1(1)<xy(k+1).point1(1)
rect=[xy(k).point2(1) xy(k).point2(2) abs (xy(k).point1(2)-xy(k).point2(2)) abs (xy(k).point1(1)-xy(k+1).point1(1))];
else
rect=[xy(k+1).point2(1) xy(k+1).point2(2) abs (xy(k).point1(2)-xy(k).point2(2)) abs (xy(k).point1(1)-xy(k+1).point1(1))];
end
end
end
if rect(4)>width
rectangle('position',rect,'Linewidth',2,'EdgeColor','r')
end
end
This is my code and i am getting an error saying Dot indexing is not supported for variables of this type.
Walter Roberson
on 2 Nov 2022
lines is not defined by that code.
Accepted Answer
More Answers (11)
elvis danso
on 11 May 2019
6 votes
You get this error when you open GUI straight from the .fig directly. Do not do so, instead from the .m script opened at the editor, click the run button to open the GUI. That is the magic!
1 Comment
Walter Roberson
on 11 May 2019
This is not quite accurate for what was happening for the user. They were using multiple GUIDE-created GUIs, not realizing that the handles structure managed by GUIDE is always relative to the figure (there is no global one for all of the GUIs together.)
They were also specifically using open_fig() on the extra GUIs rather than executing the GUIs. This has the same underlying issue as you refer to, that this does not execute the initialization code for that GUI. However, the solution for them is not to go to the editor and click the Run button, as they were opening the extra GUIs under program control, so they needed to execute the sub-GUIs by name (to cause their initialization to be run) instead of just lauching the figure.
Steven Lord
on 29 May 2018
0 votes
Set an error breakpoint and run your code. If this problem occurs again, MATLAB will enter debug mode where the error occurs. Examine the variables on that line. If the error occurs on the line 268 that you quoted ( set(handles.edit6,'string',fullname) ) I'm almost certain that the problem is what Guillaume suggested, that handles is not a struct array as you expected it to be.
1 Comment
Walter Roberson
on 5 Jan 2019
You have not given us the source for some of the functions. You have not given us the code that sets local. You have not given us the external functions you invoke. You have not told us the exact line the problem occurs on. You have barely commented the code.
We are not going to be able to debug this for you.
Anudeep Peddi
on 23 Feb 2019
filename = 'users/anudeep/desktop/a11.txt';
delimiterIn = ' ';
headerlinesIn = 1;
A = importdata(filename,delimiterIn,headerlinesIn);
for k = [3:5]
disp(A.colheaders{1, k})
disp(A.data(:, k))
disp(' ')
end
I am getting an error "Dot indexing is not supported for variables of this type".
1 Comment
Walter Roberson
on 23 Feb 2019
When importdata does not detect any text then it returns a numeric matrix not a struct .
Charanraj
on 28 Nov 2019
0 votes
I got a similar error of Dot indexing. But unable to find loop where the error exists :( I have attached a pic that tells about the error when I try to initial voltage for a capacitor in simscape using simulink.
Any guess or guideline to correct this error can be helpful. Thanks in advance.

3 Comments
Image Analyst
on 28 Nov 2019
Please paste in all the contents of the callback function. We need to see it.
Chances are you're trying to access a field of a structure, table, or class object when MATLAB thinks the variable is not a structure, table, or class object.
Thanks Image Analyst.
For close_system(gcb), I don't get any results in command window.
For power_initstates(bdroot(gcb),gcb), I get the following-
Dot indexing is not supported for variables of this
type.
Error in power_initstates_pr
Error in power_initstates_pr
Error in power_initstates (line 28)
power_initstates_pr(varargin{:});
Error while evaluating UIControl Callback.
Thanks
Walter Roberson
on 28 Nov 2019
It looks to me as if you are using Simulink, possibly SimScape Electrical (formerly SimPowerSystems). The error appears to be happening somewhere while executing the MaskDialog callback of powergui . The line with the error appears to be within a .p file or similar. I cannot tell what is happening. It might be a bug.
Julián Aristizabal
on 6 May 2020
That´s the code:
rto = get_param('temperatura_pid/Gain1', 'RuntimeObject');
str = num2str(rto.OutputPort(1).Data);
statestxt =findobj('Tag', 'Resultado');
set(statestxt, 'string', str);
n=str2num(get(statestxt, 'String'));
That´s the error:
Dot indexing is not supported for variables of this type.
Error in interfaz_temp>Visualizar_Callback (line 135)
str = num2str(rto.OutputPort(1).Data);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in interfaz_temp (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)interfaz_temp('Visualizar_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

I don´t know what is wrong, thanks for your help.
8 Comments
Walter Roberson
on 6 May 2020
For whatever reason, rto.OutputPort is not a struct or object at that point. For example it might be []
Julián Aristizabal
on 6 May 2020
But I need to use that line of code to collect output port data from Simulink model to GUI
Walter Roberson
on 6 May 2020
Use the debugger to put a breakpoint at that line of code Visualizar_Callback (line 135). Examine the class() of rto.OutputPort and size() of it.
Walter Roberson
on 6 May 2020
See https://www.mathworks.com/matlabcentral/answers/52907-simulink-get_param-and-runtimeobject#answer_64472 -- the RuntimeObject is only accessible during simulation.
Julián Aristizabal
on 6 May 2020
The problem is that variable rto = get_param('temperatura_pid/Gain1', 'RuntimeObject'); is empty, as if get_param didn't read the gain in simulink.
I've tried to solve it but I dont know what is wrong
Walter Roberson
on 6 May 2020
Is the simulation paused at the time you ask for the RunTime object?
RunTime objects are not for reading out the "final" value of an object; they are only for use while the object is running. If you need the final version, use ToWorkspace or similar.
Julián Aristizabal
on 6 May 2020
And what kind ok block can I change for the constant in order to the simulation never stops?
Walter Roberson
on 6 May 2020
set_param('temperatura_pid', 'StopTime', 'inf')
ABDULLAH DURMUS
on 13 May 2020
Edited: ABDULLAH DURMUS
on 13 May 2020
0 votes
Hello, I'm new to matlab. I need your help for my homework.
I get the error for when I run it through the GUI. I did not receive an error when I run it through the editor.
error: Dot indexing is not supported for variables of this type.
Error in untitled> pushbutton1_Callback (line 93) axes (handles.axes1); Error in gui_mainfcn (line 95) feval (vararg the {}); Error in untitled (line 42) gui_mainfcn (gui_State, varargin {:});
Can you help for the solution
Thank you
1 Comment
ABDULLAH DURMUS
on 13 May 2020
My code on line 42: gui_mainfcn (gui_State, varargin {:}); My code on line 93: axes (handles.axes1); and My code on line 95: feval (vararg the {});
Zakarya Motea
on 3 Mar 2022
0 votes
Also make sure that the model like simulink model being called from that function is not opened in another directory. this was the main problem for me, in order to make sure that the model is closed
type
close_system('modelname')
if it ask for saving
save_system('modelname')
if this going to happen too many times just embeed this code in the section of the code for closing the GUI.
kevin harianto
on 6 Apr 2022
Edited: Stephen23
on 6 Apr 2022
0 votes
i got a Dot indexing is not supported for variables of this type.
image = ptcloud.Location;
Error in ()
I = helperPointCloudToImage(Location);
as well for this code: (goal is to increase pointCloud resolution to be at minimum 64, 1856, 5 at the end)
EDIT: copyright code removed.
Alon Zaharony
on 28 Apr 2022
0 votes
Here is how i solved this issue. Not sure if that solution is relevant for all the cases, but worth a try:
Hello, I am a begineer on Matlab. Recently, I download an open-source tool to deal with some data. The Link is here:
While I was using the ' Rough Crop' function, the error is always ' Dot indexing is not supported for variables of this type'.
I attach the Code and some pics here.
Any help or tips are really helpful to me. I really appreciate it.
Thank you!

2 Comments
Walter Roberson
on 17 Aug 2022
Looking at the tutorial briefly, it appears that tool requires MS Windows with Excel installed ? We would probably also need an example data file to test with.
Jiale Ji
on 17 Aug 2022
Yeah, sure. I attach an example data document here.
Thank you so much, Walter.
Sharath
on 28 Dec 2022
0 votes
i am new to matlab, what should i write code for callback in 'app designer' 

1 Comment
Walter Roberson
on 28 Dec 2022
You have not defined what you want the App Designer callback to do
These days you would generally configure your model for Single Simulation Output https://www.mathworks.com/help/simulink/gui/single-simulation-output.html and you would invoke sim() to run the model, and then extract the appropriate information from the simulation output object. See for example https://www.mathworks.com/help/simulink/slref/sim.html?searchHighlight=sim%20&s_tid=srchtitle_sim%20_1#bvgu1qs
Categories
Find more on Matrix Indexing 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!