How to make constants global
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
the cyclist
2022년 10월 20일
편집: the cyclist
2022년 10월 20일
The first google hit for searching global matlab is this documentation page on how to define global variables.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Google에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!