Error: Dot indexing is not supported for variables of this type when initializing an array

346 views (last 30 days)
When trying to initialize an array I get the following error:
Unable to perform assignment because dot indexing is not supported for variables of this type.
Error in PhaseAmplitudeCouple (line 300) Comodulogram.R = zeros(length(PhaseFreqVector),length(AmpFreqVector)); here is the relevant code:
PhaseFreqVector = 0:1:50;
AmpFreqVector = 0:5:200;
Comodulogram.R = single(zeros(length(PhaseFreqVector),length(AmpFreqVector)));
  4 Comments
jonas
jonas on 10 Oct 2018
Edited: jonas on 10 Oct 2018
That's not how it works. If the name is empty, then yes, you will create a structure with a field R. If the name is already taken, then matlab will try to create a field to said variable. The problem is that the variable is a cell and cells have no field names, which explains your error message.
You cannot have a variable Comodulogram that is both a cell and a structure, they are different classes.
Anshuman Anshuman
Anshuman Anshuman on 24 Nov 2020
I am getting the same error. I am trying to learn character recognition so I have found this code online and trying to run it but getting the error in the line axes(handles.axes6). can you help?
%% reading the image from the user
[filename, pathname] = ...
uigetfile({'*.jpg';'*.jpeg';'*.png';'*.*'},'Select Image File');
I=strcat(pathname,filename);
% figure(1);
%imshow(I);
axes(handles.axes6);% <----getting error here
imshow(I);
set(handles.pushbutton13,'Enable','on')
helpdlg('Image has been Loaded Successfully. Choose an algorithm and train the network ',...
'Load Image');

Sign in to comment.

Answers (2)

Jos (10584)
Jos (10584) on 10 Oct 2018
As described in the comments, this produces the same error:
A = {} ; % cell
A{1}.x = 1:10 % -> error!
% Unable to perform assignment because dot indexing is not supported for variables of this type.
The overcome this functionally, you can either delete the variable using clear, or overwrite the contents of the variable using the struct function, as in:
A = {}
A = struct('r',1:10) % overwrite
  2 Comments
kevin harianto
kevin harianto on 6 Apr 2022
Edited: Stephen23 on 6 Apr 2022
Is there any ways to overwrite the contents in pointCloud inorder to meet the requirements for seeting up image?
error: Dot indexing is not supported for variables of this type.
Error in (line 164)
image = ptcloud.Location;
Error in (line 120)
I = helperPointCloudToImage(Location);
EDIT: Copyright code removed.

Sign in to comment.


Vijay Khanijow
Vijay Khanijow on 4 May 2021
I also get " dot indexing is not supported for this type of variable" when i submit code for lrCostFunction in Ex 3 of week 4 of Machine learning by Andrew Ng, Stanford. Any Help will be useful and appreciated.

Community Treasure Hunt

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

Start Hunting!