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

# Solution 167366

Submitted on 23 Nov 2012 by Paul Peeling

Correct

102Size
`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

```%%
C =   [1     1     1     0
0     0     0     0
0     1     0     1];
K = 2;
[A,B] = ebmf(C,K);
assert(isequal(A*B,C))
assert(isequal(unique(A),[0; 1]))
assert(isequal(unique(B),[0; 1]))
assert(all(size(A)==[size(C,1),K]))
assert(all(size(B)==[K,size(C,2)]))
```

2
Pass

```%%
C = [1     0     0
1     0     0
1     1     0];
K = 3;
[A,B] = ebmf(C,K);
assert(isequal(A*B,C))
assert(isequal(unique(A),[0; 1]))
assert(isequal(unique(B),[0; 1]))
assert(all(size(A)==[size(C,1),K]))
assert(all(size(B)==[K,size(C,2)]))
```

3
Pass

```%%
C = [0     0     0     0     0     0     0     0     0     0
0     0     0     0     0     0     0     0     0     0
0     0     0     0     0     0     0     0     0     0
0     0     0     0     0     0     0     0     0     0
1     0     0     0     1     1     1     0     1     0
1     0     0     0     1     1     1     0     1     0
1     0     0     0     1     1     1     0     1     0
0     0     0     0     0     0     0     0     0     0
0     0     0     0     0     0     0     0     0     0
0     0     0     0     0     0     0     0     0     0];
K = 1;
[A,B] = ebmf(C,K);
assert(isequal(A*B,C))
assert(isequal(unique(A),[0; 1]))
assert(isequal(unique(B'),[0; 1]))
assert(all(size(A)==[size(C,1),K]))
assert(all(size(B)==[K,size(C,2)]))
```

4
Pass

```%% Added another small test case
C = [1     0     1
1     1     1
0     1     0];
K = 2;
[A,B] = ebmf(C,K);
assert(isequal(A*B,C))
assert(isequal(unique(A),[0; 1]))
assert(isequal(unique(B'),[0; 1]))
assert(all(size(A)==[size(C,1),K]))
assert(all(size(B)==[K,size(C,2)]))
```

5
Pass

```%% A degenerate problem
C = [0     0     1
0     0     0
0     0     1];
K = 2;
[A,B] = ebmf(C,K);
assert(isequal(A*B,C))
assert(isequal(unique(A),[0; 1]))
assert(isequal(unique(B'),[0; 1]))
assert(all(size(A)==[size(C,1),K]))
assert(all(size(B)==[K,size(C,2)]))
```