Effacer les filtres
Effacer les filtres

Tracking failed integral2() inside a for loop

1 vue (au cours des 30 derniers jours)
Luqman Saleem
Luqman Saleem le 2 Mar 2024
Commenté : Luqman Saleem le 2 Mar 2024
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

Réponse acceptée

Walter Roberson
Walter Roberson le 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.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by