Why does data deleted from the workspace after execution the code ?

조회 수: 11 (최근 30일)
omar th
omar th 2022년 8월 15일
댓글: omar th 2022년 8월 15일
If I have the below code, why the data are erased from the workspace after finishing the excution of the code ?
function something
while
for i
calculations
end
if condition
break
end
end
end

채택된 답변

Image Analyst
Image Analyst 2022년 8월 15일
Because it's a function, not a script. Variables from a script wil remain in the base workspace after the script finishes. With functions, once the function finishes and returns, the variables internal to the function vanish.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by