What are variable scopes?
이전 댓글 표시
I looked at the articles on MathWorks, and I still do not understand variable scopes. Can someone please give me a simpler definition of what variable scopes are, and why they are important? Thank you!
채택된 답변
추가 답변 (1개)
darova
2019년 10월 16일
Example: sections between function .. end are scopes of variables
function main
x = linspace(0,2);
y1 = f1(x);
y2 = f2(x);
plot(x,y1,x,y2)
end
function y = f1(x)
% can't acess 'b'
% disp(b)
a = 2;
y = x.^2 + a;
end
function y = f2(x)
% can't acces 'a'
% disp(a)
b = 3;
y = y.^2 * b;
end
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!