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

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 Kommentare

jonas
jonas am 10 Okt. 2018
Bearbeitet: jonas am 10 Okt. 2018
Worked for me, you probably have a non-struct variable called Comodulogram already in your workspace.
Currently I have a cell named Comodulogram. I was gifted this code, but I believe Comodulogram.R is supposed to create a struct within the cell?
jonas
jonas am 10 Okt. 2018
Bearbeitet: jonas am 10 Okt. 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.
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');

Melden Sie sich an, um zu kommentieren.

Antworten (2)

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 Kommentare

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.
@kevin harianto: please do not post copyright code on this forum.

Melden Sie sich an, um zu kommentieren.

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.

Kategorien

Gefragt:

am 10 Okt. 2018

Kommentiert:

am 6 Apr. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by