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 138385

Submitted on 12 Sep 2012 by James

Correct

21Size
Leading solution size is 15.
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
 
%%
v=[1 0 0 -1];
w=[1 -1];
assert(integ(v,w))
q =
     1     1     1
r =
     0     0     0     0
ans =
     1
2
Pass
 
%%
v=[2 9 6 -1 16 -5];
w=[2 3 -1 5];
assert(integ(v,w))
q =
     1     3    -1
r =
     0     0     0     0     0     0
ans =
     1
3
Pass
 
%%
v=[1 4 10 20 35 50 58 58 49 30];
w=1:6;
assert(integ(v,w))
q =
     1     2     3     4     5
r =
     0     0     0     0     0     0     0     0     0     0
ans =
     1
4
Pass
 
%%
v=1:10;
w=1:6;
assert(~integ(v,w))
q =
     1     0     0     0     0
r =
     0     0     0     0     0     0     7     8     9    10
ans =
     0
5
Pass
 
%%
v=3:12;
w=-3:2;
assert(~integ(v,w))
q =
   -1.0000   -0.6667   -0.8889   -1.1852   -1.5802
r =
  Columns 1 through 6
         0         0         0         0         0    6.3210
  Columns 7 through 10
    9.6420   12.9630   14.9506   15.1605
ans =
     0