How to call functions from inside an if statement only once?
Afficher commentaires plus anciens
How can I call both decision and implement functions from inside the if statement just for once, and then call them without using the if statement for the rest of time steps?
N = numnodes(G); % number of nodes in the steady state
[~,M] = initial(~); % attacking the network
% M is the number of inactive nodes
for tt = 2: 50
if any(needRemoveNode)
[~,M] = Stages(needRemoveNode,M); % attacking the network
else
break
end
% Calling the recovering functions
if M(tt) >= 0.3 * N % triggering level (delay response)
[G_dmg, ~] = decision(~);
[G_dmg] = implement(G_dmg, ~);
end
end
Thanks!
Réponse acceptée
Plus de réponses (1)
Jan
le 13 Nov 2021
I'm not sure if I understand you correctly, but maybe:
for tt = 2: 50
...
if tt > 2 || M(tt) >= 0.3 * N
[G_dmg, ~] = decision(~);
[G_dmg] = implement(G_dmg, ~);
end
end
1 commentaire
Waseem AL Aqqad
le 13 Nov 2021
Modifié(e) : Waseem AL Aqqad
le 13 Nov 2021
Catégories
En savoir plus sur Conway's Game of Life dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!