For loop that references two different arrays

Do you even need to collect the last vector? This is more than 3x faster again:

x = 0:99
xhat = mean(x)
xminxhat = x .- xhat
1 Like