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

logicalOutput = arrayfun(@passingCentralZone, input_data.id(1:10), 'ErrorHandler',@(varargin) false);
% simpler fun handle: ^^^^^^^^^^^^^^^^^^^
% error handling function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Atanu
Atanu 2022년 12월 4일
Thanks for your comment. I am using this simpler function handle.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2022년 12월 4일

0 개 추천

logicalOutput = arrayfun(@(id) passingCentralZone(id), input_data.id(1:10), 'ErrorHandler', @(s,varargin) false());

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2022년 12월 4일

댓글:

2022년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by