필터 지우기
필터 지우기

how to resolve the 'dot indexing not supported for this type of variable' error when creating GUIs with GUIDE?

조회 수: 1,447 (최근 30일)
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
Loku Bhanu Teja R
Loku Bhanu Teja R 2022년 11월 2일
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
Walter Roberson 2018년 7월 1일
You used GUIDE to construct these GUIs.
When you use GUIDE, then the "handles" structure that is passed into your function always refers to information stored against the figure that the graphic element is in. "handles" is not a global structure, it is a per-GUI structure, and you have constructed three separate GUI.
You need to change
set(handles.edit6,'string',fullname);
to
edit6 = findobj(0, 'tag', 'edit6');
set(edit6, 'string', fullname);
  댓글 수: 10
jianpeng
jianpeng 2022년 3월 23일
Warning: Error executing a listener callback for the event ButtonExited defined for class matlab.graphics.primitive.canvas:
Error using getDatetimeSettings
The default value of the property 'MonthsOfYear' in class 'datetime' is invalid:
Variables of this type do not support indexing with points.
What is the reason for this error in the drawing, please answer thank uu!!!!
Walter Roberson
Walter Roberson 2022년 3월 23일
I think we are going to need your code -- and your .fig too if you used GUIDE. You can attach them.
... though I suspect that you might have some third-party code that is interfering with MATLAB.

댓글을 달려면 로그인하십시오.

추가 답변 (11개)

elvis danso
elvis danso 2019년 5월 11일
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
Walter Roberson
Walter Roberson 2019년 5월 11일
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
Steven Lord 2018년 5월 29일
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
Walter Roberson
Walter Roberson 2019년 1월 5일
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
Anudeep Peddi 2019년 2월 23일
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".

Charanraj
Charanraj 2019년 11월 28일
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
Charanraj
Charanraj 2019년 11월 28일
편집: Charanraj 2019년 11월 28일
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
Walter Roberson 2019년 11월 28일
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
Julián Aristizabal 2020년 5월 6일
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
Julián  Aristizabal
Julián Aristizabal 2020년 5월 6일
And what kind ok block can I change for the constant in order to the simulation never stops?

댓글을 달려면 로그인하십시오.


ABDULLAH DURMUS
ABDULLAH DURMUS 2020년 5월 13일
편집: ABDULLAH DURMUS 2020년 5월 13일
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
ABDULLAH DURMUS
ABDULLAH DURMUS 2020년 5월 13일
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
Zakarya Motea 2022년 3월 3일
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
kevin harianto 2022년 4월 6일
편집: Stephen23 2022년 4월 6일
i got a Dot indexing is not supported for variables of this type.
Error in (line 163)
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
Alon Zaharony 2022년 4월 28일
Here is how i solved this issue. Not sure if that solution is relevant for all the cases, but worth a try:

Jiale Ji
Jiale Ji 2022년 8월 16일
편집: Jiale Ji 2022년 8월 16일
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
Walter Roberson
Walter Roberson 2022년 8월 17일
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
Jiale Ji 2022년 8월 17일
Yeah, sure. I attach an example data document here.
Thank you so much, Walter.

댓글을 달려면 로그인하십시오.


Sharath
Sharath 2022년 12월 28일
i am new to matlab, what should i write code for callback in 'app designer'
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 12월 28일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by