Maybe a supplement: This error occurs when I use the "Run" (green arrow) or the newly implemented function "Run to Here" at the left side of the script lines. When I mark the whole script and press F9, the error occurs also. When I mark each single line and execute it by F9 and go to the whole script in this manner line by line, the error does not occur.
A problem using arrayfun for searching nested elements
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Jiri Hajek
am 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.
Siddharth Bhutiya
am 6 Jan. 2023
It looks like you might be running into this bug: https://www.mathworks.com/support/bugreports/2804253
Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!