MATLAB: List of lists while loop

arrayhomeworklist of listsMATLABwhile

Best Answer

No need for a cell array if feathers is a number (not a string). You need to index the array_of_ducks array however. You can do that with an iteration counter:
ducks = 1
additional_ducks = 0.5
loopCounter = 1;
maxIterations = 10000; % Whatever you don't expect to ever exceed. A failsafe to prevent infinite loops.
while ducks <= 3 && loopCounter < maxIterations
feathers = (math here)
ducks = ducks + additional_ducks;
array_of_ducks(loopCounter) = feathers; % No braces needed.
loopCounter = loopCounter + 1; % Increment loop counter.
end
Related Question