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 238215

Submitted on 30 Apr 2013 by G K

Correct

73Size
Leading solution size is 64.
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
 
%%
user_solution = fileread('radialZernike.m');
assert(isempty(strfind(user_solution,'regexp')));
assert(isempty(strfind(user_solution,'2str')));
assert(isempty(strfind(user_solution,'str2')));
assert(isempty(strfind(user_solution,'interp')));
assert(isempty(strfind(user_solution,'printf')));
assert(isempty(strfind(user_solution,'assert')));

                    
2
Pass
 
%%
n = 0;
m = 0;
P_correct = [1];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0
3
Pass
 
%%
n = 1;
m = 1;
P_correct = [1 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0
4
Pass
 
%%
n = 2;
m = 0;
P_correct = [2 0 -1];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -2
ans =
     0
5
Pass
 
%%
n = 2;
m = 2;
P_correct = [1 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0
6
Pass
 
%%
n = 3;
m = 1;
P_correct = [3 0 -2 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -2
ans =
     0
7
Pass
 
%%
n = 3;
m = 3;
P_correct = [1 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0
8
Pass
 
%%
n = 4;
m = 0;
P_correct = [6 0 -6 0 1];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -4
ans =
    -2
ans =
     0
9
Pass
 
%%
n = 4;
m = 2;
P_correct = [4 0 -3 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -2
ans =
     0
10
Pass
 
%%
n = 4;
m = 4;
P_correct = [1 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0
11
Pass
 
%%
n = 5;
m = 1;
P_correct = [10 0 -12 0 3 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -4
ans =
    -2
ans =
     0
12
Pass
 
%%
n = 5;
m = 3;
P_correct = [5 0 -4 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -2
ans =
     0
13
Pass
 
%%
n = 5;
m = 5;
P_correct = [1 0 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0
14
Pass
 
%%
n = 6;
m = 0;
P_correct = [20 0 -30 0 12 0 -1];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -6
ans =
    -4
ans =
    -2
ans =
     0
15
Pass
 
%%
n = 6;
m = 2;
P_correct = [15 0 -20 0 6 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -4
ans =
    -2
ans =
     0
16
Pass
 
%%
n = 6;
m = 4;
P_correct = [6 0 -5 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -2
ans =
     0
17
Pass
 
%%
n = 6;
m = 6;
P_correct = [1 0 0 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0
18
Pass
 
%%
n = 7;
m = 1;
P_correct = [35 0 -60 0 30 0 -4 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -6
ans =
    -4
ans =
    -2
ans =
     0
19
Pass
 
%%
n = 7;
m = 3;
P_correct = [21 0 -30 0 10 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -4
ans =
    -2
ans =
     0
20
Pass
 
%%
n = 7;
m = 5;
P_correct = [7 0 -6 0 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -2
ans =
     0
21
Pass
 
%%
n = 7;
m = 7;
P_correct = [1 0 0 0 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0
22
Pass
 
%%
n = 8;
m = 0;
P_correct = [70 0 -140 0 90 0 -20 0 1];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -8
ans =
    -6
ans =
    -4
ans =
    -2
ans =
     0
23
Pass
 
%%
n = 8;
m = 2;
P_correct = [56 0 -105 0 60 0 -10 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -6
ans =
    -4
ans =
    -2
ans =
     0
24
Pass
 
%%
n = 8;
m = 4;
P_correct = [28 0 -42 0 15 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -4
ans =
    -2
ans =
     0
25
Pass
 
%%
n = 8;
m = 6;
P_correct = [8 0 -7 0 0 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -2
ans =
     0
26
Pass
 
%%
n = 8;
m = 8;
P_correct = [1 0 0 0 0 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0
27
Pass
 
%%
n = 9;
m = 1;
P_correct = [126 0 -280 0 210 0 -60 0 5 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -8
ans =
    -6
ans =
    -4
ans =
    -2
ans =
     0
28
Pass
 
%%
n = 9;
m = 3;
P_correct = [84 0 -168 0 105 0 -20 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -6
ans =
    -4
ans =
    -2
ans =
     0
29
Pass
 
%%
n = 9;
m = 5;
P_correct = [36 0 -56 0 21 0 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -4
ans =
    -2
ans =
     0
30
Pass
 
%%
n = 9;
m = 7;
P_correct = [9 0 -8 0 0 0 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
    -2
ans =
     0
31
Pass
 
%%
n = 9;
m = 9;
P_correct = [1 0 0 0 0 0 0 0 0 0];
assert(isequal(radialZernike(n,m),P_correct));
ans =
     0