In Matlab, I am using a custom function with varargin as input, that acts on global variables that are cell arrays filled with structure arrays. I obtain following error message:
Cell contents reference from a non-cell array object.
In the first place, I would like to ask if anyone encountered this problem in the same setting as I did. And apart from the context, what is the meaning of this error message?
I have difficulties in reducing this problem to a MWE. The basic idea is the following. A 3x3 cell-array myArray is constructed. In the same .m file, it is possible to access its content at position {1,3} by using myArray{1,3}. Now I want to remove the reading function from main.m and define a custom function that takes the position as input and displays the content of myArray at that position.
%main.m
global myArray
%define myArray
...
%display content
myContent(i,j)
with
function [] = myContent(indexI,indexJ)
    global myArray
    disp(myArray{indexI,indexJ})
end
This results in the mentioned error message
Cell contents reference from a non-cell array object.
Error in myContent (line .)
myArray{indexI,indexJ}
 
                        
I think you are trying to address the structure-arrays with curly braces
{}instead of the normal ones(). This will give you exactly the stated error-message.Edit: Avoid using
iandjas variable names since they are used for the imaginary unit. See this post for details. My example already usesaandbinstead.Try the following code for a demo on how to address the types you mentioned: