While assigning a variable, is the variable cleared by default before the assignment?
이전 댓글 표시
Hello all,
please clarify my doubt regarding variable assignment in MATLAB.
say
for iLoop=1:100%Line_1
output=someCalculation(iLoop);%Line_2
someOtherCalculation(output);%Line_3
...
...
end%Line_n
In line 2, we can see that output is written with value from someCalculation(). Is output, internally cleared before executing the next loop?
The background of my question is, one of our scripts (I realise scripts are bad. But legacy scripts), was creating a variable 'output' - (quite a huge variable - 1000s of MBytes) in every iteration.
In one of the iteration, there was memory error in Line 2. I have inserted a 'clear output' between line 1 and 2, and expect script to run without memory error.
Is my expectation correct?
In other words, while creating output for ith iteration, is the size of output from i-1 th iteration a bottleneck in terms of memory?
댓글 수: 1
Rik
2019년 5월 15일
Shouldn't you be able to check this by creating an array that should fill most of your memory and comparing the results of running it with and without a clear statement?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!