How to make constants global
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a number of functions in my code that i'm currently using, but i'm having to define constants each time inside the functions. is there a way to make the constants 'global' so that all functions can use them without having to be defined each time in each function?
E.g.
function[total_loss] = losses(VG,VD)
dt = 0.1; %Timestep
Vg = trapz(VG)*dt;
Vd = trapz(VD)*dt;
total_loss = Vg+Vd;
end
I've defined the timestep, dt. Is there a way to define it so that other functions can use it?
0 commentaires
Réponses (1)
the cyclist
le 20 Oct 2022
Modifié(e) : the cyclist
le 20 Oct 2022
The first google hit for searching global matlab is this documentation page on how to define global variables.
0 commentaires
Voir également
Catégories
En savoir plus sur Google dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!