I have to insert values from a for loop into an array, but can't get it to work as the loop variable starts at 0. I have tried the two following approaches, but neither work. Any advice or critisism would be very helpful.
Attempt 1 –
a = 500b = 1000for i=0:0.05:2 elements = a * i area(i) = b + elements end
Attempt 2
a = 500 b = 1000area = [ ];for i=0:0.5:2 elements = a*i area = [b + elements]end
Attempt 1 throws up an error message while attempt 2 just doesn't insert the values into an array. Any help would be appreciated. Thank you!
Best Answer