Why does data deleted from the workspace after execution the code ?
조회 수: 11 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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 Center 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!