Azzera filtri
Azzera filtri

Tracking failed integral2() inside a for loop

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 2 Mar 2024
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.

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by