Index starts at 1... why does the error refer to zero index

error2 error

You’re trying to access an empty array at index 1.

Actually I want to push elements in the new array

Then you should use push!()

1 Like

Unlike Matlab, you need to use push! — Julia won’t automatically grow arrays by assigning to them out-of-bounds.