Skip to main content

11.9) for...end Statement: Examples (cont'd)


[matlab]
>> % An example of a 5 sample trailing edge running mean
>> n=100;
>> data=rand(n,1);
>> output=zeros(n,1);
>> for i=5:n
>> output(i,1)=mean(data(i-4:i,1));
>> end
>> output(1:4)=NaN
[/matlab]