(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

I get the error that the variable changes size with each loop iteration then it suggests that I preallocate memory to overcome this. How would I do that?

2. Relevant equations

none

3. The attempt at a solution

here is my code

t=0:0.5:5;

y(1)=1;

for i = 1:10

y(i+1) = y(i)+ (t(i)^2*0.5);

end

thanks for the help

**Physics Forums - The Fusion of Science and Community**

# How do I preallocate memory in MATLAB...

Know someone interested in this topic? Share a link to this question via email,
Google+,
Twitter, or
Facebook

Have something to add?

- Similar discussions for: How do I preallocate memory in MATLAB...

Loading...

**Physics Forums - The Fusion of Science and Community**