While assigning a variable, is the variable cleared by default before the assignment?
Mostra commenti meno recenti
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 Commento
Rik
il 15 Mag 2019
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?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!