A problem using arrayfun for searching nested elements

4 views (last 30 days)
Hello together,
basically my problem occured first after I updated from 2021 to 2022b.
I have written a large software toolbox where I structure data in classes and provide additional information to that data in class-properties stored as matlab tables.
Quite often I use the arrayfun to search arrays of class instances to elements with special conditions. For example:
idx = arrayfun(@(c) isequal(c.Condition.Properties.VariableNames{1}, MyArrayOfInstances(1).Condition.Properties.VariableNames{1}), MyArrayOfInstances);
Here, "Condition" is a property stored as table and I want to find all instances which are equal in this element to the first array element.
Basically, this works fine. But when I run a script which uses the toolbox and does some stuff and then executes the line above, it throws me the error:
"Error using . " Cannot find function "@(c) (isequal(c.Condition.Properties..."
But when I try-catch the error and set a breakpoint in the catch branch and then manually execute the line by marking and pressing F9 every thing works fine and does what its meant to do. This makes it difficult to debug.
At some other points in the toolbox with a similar syntax, I got a similar error:
"Error using indexing" Cannot find function "@(c) (isequal(c.Condition.Properties..."
Do you have any idea how to solve this without changing various classes, methods and scripts from colleagues and me?
I think, this may have to do with the change to 2022b because in the years before, I didn't face this problem.
  3 Comments
Jiri Hajek
Jiri Hajek on 4 Jan 2023
Hi, this reminds me of a similarly quasi-random and virtually un-debuggable error which I met not long ago. In your case however, it is at least occuring regularly and probably can be documented / replicated by a small exaple. So I'd encourage you to forward this directly to your Mathworks distributor. It certainly looks like a bug in MATLAB.

Sign in to comment.

Answers (0)

Categories

Find more on Data Type Identification in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!