Dot indexing is not supported for variables of this type как исправить

3,069 views (last 30 days)

mohanish

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.

Accepted Answer

Walter Roberson

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);


More Answers (11)

elvis danso

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!


Steven Lord

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.


Anudeep Peddi

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

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.


Julián  Aristizabal

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.


ABDULLAH DURMUS

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


Zakarya Motea

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

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

Here is how i solved this issue. Not sure if that solution is relevant for all the cases, but worth a try:


Jiale Ji

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!


Sharath

i am new to matlab, what should i write code for callback in ‘app designer’

When I run the code below, I get the error «

Unable to perform assignment because dot indexing is not supported for variables of this type.

» Any idea on how to fix it?

dots.nDots = 100;

for dots = 1:dots.nDots
    dots.x = (rand(1,dots.nDots));   
    dots.y = (rand(1,dots.nDots));
end

asked Jun 17, 2019 at 14:27

Kathia's user avatar

The line:

dots.nDots = 100;

creates the variable dots as a structure array with a field nDots. However, you overwrite the variable dots when you begin your for loop:

for dots = 1:dots.nDots

At this point, the variable dots becomes an integer value. When you then try to access the field nDots you get the error you see, because dots is no longer a structure with that field.

If you simply rename your loop variable, you will no longer get that error:

dots.nDots = 100;

for iDot = 1:dots.nDots
  dots.x = (rand(1, dots.nDots));   
  dots.y = (rand(1, dots.nDots));
end

However, it’s not clear what you hope to accomplish with this loop. All this will do is repeatedly overwrite dots.x and dots.y with a new set of 100 random values each, 100 times over.

answered Jun 17, 2019 at 14:38

gnovice's user avatar

gnovicegnovice

125k15 gold badges256 silver badges359 bronze badges

2

Dot Indexing is Not Supported for Variables of This Type

As I understand, this error occurs when we define a variable as numerical and than call it as a structural. In another words, dot indexing is a way of accessing data fields in a type of matlab variable called a struct (structure).

Problem is that I have no intention of doing this, I am only using dots to multiply terms in a vector (numerical variable) with some other variables/numbers. I have no structural variables and so I don’t want to access data fields.

This is an example from my code:

A2e = x1e.* tau12* G12 where tau12 and G12 are symbolic variables and x1e is a vector 1×10.

As the comments point out, it is not clear why you are getting this error, but I can tell you what is causing it. Dot indexing is a way of accessing data fields in a type of Matlab variable called a struct. In your snippet files(j) is not a struct.

For example, you cannot do this:

>> s = {}; % s is a cell array (not a struct)
>> g = {};
>> g{1} = lala;
>> s{1} = g;
>> s.g % cannot access g using this syntax
Dot indexing is not supported for variables of this type.

But if you make s a struct, you can:

>> s = struct
s = 
  struct with no fields.

>> s.item1 = g; % create a field called item1 to hold the stuff in g
>> s.item1 % now you can use dot indexing to access the stuff you put in there

ans =

  1×1 cell array

    {lala}

I would guess that this snippet is part of a function where files is an argument or down the line of a script in which files is earlier defined. Probably the other day with your colleague, you had files set to a variable that is indeed an array of structures with the items name etc inside of them. Since then, something changed the value of files to an array of non-struct types.

matlab – Dot indexing is not supported for variables of this type for a code that was running perfectly fine?

indexingmatlab

I am extracting data from a table and storing the 1*1 cursor in curs.

The code is something like this:

curs = exec(conn,['Select D***V***e,D***T***S***p From ' **** ' where Attribute = "****"']);
    curs = fetch(curs);
    Data = curs.Data;
    close(curs);
s = string(Data.D***T***S***p);

This gives me the error | | | Dot indexing is not supported for variables of this type. Error in WaveletCode (line 11) s = string(Data.DataTimeStamp);|||

The Data is a 30000*2 cell in below format

84.3363037100000    '2017-06-01T00:00:03.5+10:00'
99.5158004800000    '2017-06-01T00:01:03.5+10:00'

Can someone help me figure out what is he issue with the code.

Related Question

    Понравилась статья? Поделить с друзьями:
  • За ночь разряжается аккумулятор как найти
  • Как исправить ошибку в фортнайт невозможно зайти на серверы
  • Как найти нормальное напряжение в стержне
  • Как исправить в трудовой несколько неправильных записей
  • Как найти похожую картинку в поиске