필터 지우기
필터 지우기

Tracking failed integral2() inside a for loop

조회 수: 1 (최근 30일)
Luqman Saleem
Luqman Saleem 2024년 3월 2일
댓글: Luqman Saleem 2024년 3월 2일
I'm running the integral2() function within a `parfor` loop. Occasionally, the integration fails during some iterations, and I receive a warning stating "Integration was unsuccessful" along with information about the error bound. I'm wondering if there's a way to track which iterations encounter this issue and what the corresponding error bounds are, all while still inside the `parfor` loop.
For example, I want something like the following:
integrations = zeros(1,10)
fail_flags = zeros(1,10); %0 for failed integrations, 1 for successful
error_bounds = zeros(1,10)'
parfor i = 1:10
warning('off','all')
[integration, fail_flag, error_bound] = integral2(fun,...);
integrations(i) = integration;
fail_flags(i) = fail_flag;
error_bounds(i) = error_bound;
end

채택된 답변

Walter Roberson
Walter Roberson 2024년 3월 2일
Just before the integral2() call
warning('');
Just after the integral2 call
[msg, lastID] = lastwarn();
If msg is empty then the integral2() succeeded; otherwise you can examine msg and lastID to determine the success.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by