Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 239330

Submitted on 2 May 2013

Incorrect

26Size
Leading solution size is 25.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
x = [1 4 9 16 25];
y_correct = [1 3 2];
assert(isequal(seq2commondiff(x),y_correct))
ans =
     1
ans =
     1     3
ans =
     1     3     2
2
Pass
 
%%
x = [1 9 29 67 129 221];
y_correct = [1 8 12 6];
assert(isequal(seq2commondiff(x),y_correct))
ans =
     1
ans =
     1     8
ans =
     1     8    12
ans =
     1     8    12     6
3
Pass
 
%%
x = [3     4     9    23    51    98   169   269   403   576];
y_correct = [3 1 4 5];
assert(isequal(seq2commondiff(x),y_correct))
ans =
     3
ans =
     3     1
ans =
     3     1     4
ans =
     3     1     4     5
4
Pass
 
%%
x = [1 8 27 64 125 216];
y_correct = [1 7 12 6];
assert(isequal(seq2commondiff(x),y_correct))
ans =
     1
ans =
     1     7
ans =
     1     7    12
ans =
     1     7    12     6
5
Fail
 
%%
x = [2     0     2     9    22    42];
y_correct = [2 -2 4 1];
assert(isequal(seq2commondiff(x),y_correct))
Error: Assertion failed.
6
Pass
 
%%
x=[1     8    28    67   131   226]
y_correct = [1 7 13 6];
assert(isequal(seq2commondiff(x),y_correct))
x =
     1     8    28    67   131   226
ans =
     1
ans =
     1     7
ans =
     1     7    13
ans =
     1     7    13     6