Clear Filters
Clear Filters

How to use error handler for arrayfun?

3 views (last 30 days)
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 '' array
logicalOutput = arrayfun(@(id) passingCentralZone(id),;
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?
Stephen23 on 4 Dec 2022
logicalOutput = arrayfun(@passingCentralZone,, 'ErrorHandler',@(varargin) false);
% simpler fun handle: ^^^^^^^^^^^^^^^^^^^
% error handling function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Struggling in MATLAB
Struggling in MATLAB on 4 Dec 2022
Thanks for your comment. I am using this simpler function handle.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 4 Dec 2022
logicalOutput = arrayfun(@(id) passingCentralZone(id),, 'ErrorHandler', @(s,varargin) false());

More Answers (0)


Find more on Automotive in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!