Skip to main content

11.8) for...end Statement: Examples


[matlab]
>> % An example of nested for loops
>> m=100;
>> n=200;
>> average=0;
>> data=rand(m,n,3);
>> for i=1:m
>> for j=1:n
>> average=mean(data(i,j,:));
>> output(i,j)=average;
>> end
>> end
[/matlab]

Note the indentation of the for loops to improve readability. What is being calculated here?