Effacer les filtres
Effacer les filtres

Storing error values in for loop

3 vues (au cours des 30 derniers jours)
Griffin Polglaze
Griffin Polglaze le 28 Avr 2020
Réponse apportée : Rik le 28 Avr 2020
I'm sure this is a pretty simple for loop but I'm trying to store the error value for each iteration performed in my code but not too sure how to do this. The error is equal to this. Any suggestions are greatly appreciated. Thanks
error = max(abs(T - T_c), [], 'all');

Réponses (1)

Rik
Rik le 28 Avr 2020
Don't use error as a variable name. Otherwise you can just use indexing:
err=zeros(1,N);
for n=1:N
%your code goes here
err_for_this_iteration=rand;
err(n)=err_for_this_iteration;
end

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by