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

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

# Solution 176776

Submitted on 13 Dec 2012 by Aurelien Queffurust

Correct

32Size
Leading solution size is 23.
`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

```%% use gallery
filetext = fileread('your_fcn_name.m')
assert(~isempty(strfind(filetext, 'gallery')))
assert( isempty(strfind(filetext, '% gallery')))
```
```filetext =
function ans = your_fcn_name(n)
gallery('kms',n,n) ;
ans==n.^(floor(n/2))
(ans+rot90(ans))>0
%This code written by profile_id 2391181
```
2
Pass

```%%
n = 5;
expected = [0     0     1     0     0
0     1     0     1     0
1     0     0     0     1
0     1     0     1     0
0     0     1     0     0];
y_correct = logical(expected)
assert(isequal(your_fcn_name(n),y_correct))
```
```y_correct =
0     0     1     0     0
0     1     0     1     0
1     0     0     0     1
0     1     0     1     0
0     0     1     0     0
ans =
0     0     1     0     0
0     0     0     1     0
1     0     0     0     1
0     1     0     0     0
0     0     1     0     0
ans =
0     0     1     0     0
0     1     0     1     0
1     0     0     0     1
0     1     0     1     0
0     0     1     0     0
```
3
Pass

```%%
n = 9;
expected =   [ 0     0     0     0     1     0     0     0     0
0     0     0     1     0     1     0     0     0
0     0     1     0     0     0     1     0     0
0     1     0     0     0     0     0     1     0
1     0     0     0     0     0     0     0     1
0     1     0     0     0     0     0     1     0
0     0     1     0     0     0     1     0     0
0     0     0     1     0     1     0     0     0
0     0     0     0     1     0     0     0     0]
y_correct = logical(expected)
assert(isequal(your_fcn_name(n),y_correct))
```
```expected =
0     0     0     0     1     0     0     0     0
0     0     0     1     0     1     0     0     0
0     0     1     0     0     0     1     0     0
0     1     0     0     0     0     0     1     0
1     0     0     0     0     0     0     0     1
0     1     0     0     0     0     0     1     0
0     0     1     0     0     0     1     0     0
0     0     0     1     0     1     0     0     0
0     0     0     0     1     0     0     0     0
y_correct =
0     0     0     0     1     0     0     0     0
0     0     0     1     0     1     0     0     0
0     0     1     0     0     0     1     0     0
0     1     0     0     0     0     0     1     0
1     0     0     0     0     0     0     0     1
0     1     0     0     0     0     0     1     0
0     0     1     0     0     0     1     0     0
0     0     0     1     0     1     0     0     0
0     0     0     0     1     0     0     0     0
ans =
0     0     0     0     1     0     0     0     0
0     0     0     0     0     1     0     0     0
0     0     0     0     0     0     1     0     0
0     0     0     0     0     0     0     1     0
1     0     0     0     0     0     0     0     1
0     1     0     0     0     0     0     0     0
0     0     1     0     0     0     0     0     0
0     0     0     1     0     0     0     0     0
0     0     0     0     1     0     0     0     0
ans =
0     0     0     0     1     0     0     0     0
0     0     0     1     0     1     0     0     0
0     0     1     0     0     0     1     0     0
0     1     0     0     0     0     0     1     0
1     0     0     0     0     0     0     0     1
0     1     0     0     0     0     0     1     0
0     0     1     0     0     0     1     0     0
0     0     0     1     0     1     0     0     0
0     0     0     0     1     0     0     0     0
```