How to use error handler for arrayfun?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Atanu
am 4 Dez. 2022
Kommentiert: Atanu
am 4 Dez. 2022
I am trying to apply a function to an big array. The output is a logical output. I checked that this arrayfunction is working for me.
% apply function to 'input_data.id' array
logicalOutput = arrayfun(@(id) passingCentralZone(id), input_data.id(1:10));
This function will fail for a few entry where we have bad/corrupt data in the database. I want to use an error handler. Ideally I want to have nan value or logical 0 for those bad data. I looked at the documentation, but did not understand much. Can anyone please help with this?
2 Kommentare
Stephen23
am 4 Dez. 2022
logicalOutput = arrayfun(@passingCentralZone, input_data.id(1:10), 'ErrorHandler',@(varargin) false);
% simpler fun handle: ^^^^^^^^^^^^^^^^^^^
% error handling function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Akzeptierte Antwort
Walter Roberson
am 4 Dez. 2022
logicalOutput = arrayfun(@(id) passingCentralZone(id), input_data.id(1:10), 'ErrorHandler', @(s,varargin) false());
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures 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!