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!