MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayFind the mean of each consecutive pair of numbers in the input row vector. For example,

x=[1 2 3] ----> y = [1.5 2.5]

x=[100 0 0 0 100] ----> y = [50 0 0 50]

1068 correct solutions
481 incorrect solutions

Last solution submitted on Oct 31, 2014

3 players like this problem

2 Comments

Rodrigo Portugal
on 29 Mar 2013

Why is eval forbidden while regexp isn't? Don't they have the same 'nature'?

Michael Cappello
on 24 Oct 2013

It seems that the vast majority of leading solutions are size 10 or 11. If a problem has a single output, then having a return argument of 'ans' makes the size smaller. For instance:
function ans=findmean(x,y)
mean([x y])
is smaller in size than
function m=findmean(x,y)
m = mean([x y])
This seems silly, and makes me think that there is some 'trick' to these size 10&11 solutions that has little to do with good coding practices. Of course, it could just be sour grapes on my part because I can't get my sizes even close to that small.

2 Comments