Why is pre-allocating done?
Mostra commenti meno recenti
In a program why is pre-allocating done?for example using arrays of zeros
ex- A=zeros(3)
Risposta accettata
Più risposte (1)
Steven Lord
il 30 Giu 2021
2 voti
Imagine you were building a home. Which would be preferable?
- Buy a lot large enough to build the entire home.
- Build the bathroom.
- Build the bedroom.
- Build the kitchen.
- etc.
or
- Buy a lot large enough to build the bathroom.
- Build the bathroom.
- Buy a new lot large enough to hold the bathroom and a bedroom.
- Move the bathroom to the new lot.
- Build the bedroom.
- Buy a new lot large enough to hold the bathroom, a bedroom, and a kitchen.
- Move the bathroom and the bedroom to the new lot.
- Build the kitchen.
- etc.
Moving a building is hard. Ideally you don't do it, or you do it as few times as you can.
1 Commento
S Priya
il 30 Giu 2021
Categorie
Scopri di più su 2-D and 3-D Plots 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!