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

# Solution 29785

Submitted on 5 Feb 2012 by Steve Eddins

Correct

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

```%%
assert(isequal(nonuniformQuantizer(-23), -3.5));
```

2
Pass

```%%
assert(isequal(nonuniformQuantizer(0), 0.5));
```

3
Pass

```%%
assert(isequal(nonuniformQuantizer(1.1), 1.5));
```

4
Pass

```%%
assert(isequal(nonuniformQuantizer(2.9), 1.5));
```

5
Pass

```%%
assert(isequal(nonuniformQuantizer(-Inf), -3.5));
```

6
Pass

```%%
assert(isequal(nonuniformQuantizer(Inf), 3.5));
```

7
Pass

```%%
x = -4.0:0.5:4.5;
y = [-3.5 -3.5 -1.5 -1.5 -1.5 ...
-1.5 -0.5 -0.5 0.5 0.5 1.5 ...
1.5 1.5 1.5 3.5 3.5 3.5 3.5];
assert(isequal(y, nonuniformQuantizer(x)));
```

8
Pass

```%%
x = -4.0:0.5:4.5;
y = [-3.5 -3.5 -1.5 -1.5 -1.5 ...
-1.5 -0.5 -0.5 0.5 0.5 1.5 ...
1.5 1.5 1.5 3.5 3.5 3.5 3.5];
assert(isequal(y', nonuniformQuantizer(x')));
```

9
Pass

```%%
x = -4.0:0.5:4.5;
y = [-3.5 -3.5 -1.5 -1.5 -1.5 ...
-1.5 -0.5 -0.5 0.5 0.5 1.5 ...
1.5 1.5 1.5 3.5 3.5 3.5 3.5];
assert(isequal(reshape(y,3,6), ...
nonuniformQuantizer(reshape(x,3,6))));
```

10
Pass

```%%
x = -4.0:0.5:4.5;
y = [-3.5 -3.5 -1.5 -1.5 -1.5 ...
-1.5 -0.5 -0.5 0.5 0.5 1.5 ...
1.5 1.5 1.5 3.5 3.5 3.5 3.5];
assert(isequal(reshape(y,1,6,3), ...
nonuniformQuantizer(reshape(x,1,6,3))));
```