If speed is what's important you almost certainly want some kind of loop.
If it's more important not to have a loop you can satisfy your
specification with
b = reshape(repmat(mean(reshape(a,10,10),1),10),100)
although that's not what I would call a moving average.
Den tisdag 10 februari 2015 kl. 10:00:36 UTC+1 skrev paul analyst:
>
> How to quickly count the moving average with one vector and save the other
> vector?
> I have vec a and need to fill vec b moving average of a, in this same range.
> Is posible to do it whitout while ?
>
> julia> a=rand(100);
> julia> b=zeros(100);
>
> julia> b[1:10]=mean(a[1:10])
> 0.6312220153427996
>
> julia> b[11:20]=mean(a[11:20])
> 0.6356771620528772
>
> julia> b
> 100-element Array{Float64,1}:
> 0.631222
> 0.631222
> 0.631222
> 0.631222
> 0.631222
> 0.631222
> 0.631222
> 0.631222
> 0.631222
> 0.631222
> 0.635677
> 0.635677
> 0.635677
> 0.635677
> 0.635677
> 0.635677
> 0.635677
> 0.635677
> 0.635677
> ?
> 0.0
>
>
> Paul
> 0.0
>