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 238500

Submitted on 1 May 2013 by Claudio Gelmi

Correct

138Size
Leading solution size is 40.
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('chebyshev1stKindPoly.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;
P_correct = [1];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
     1
3
Pass
 
%%
n = 1;
P_correct = [1 0];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
     1     0
4
Pass
 
%%
n = 2;
P_correct = [2 0 -1];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
     2     0    -1
5
Pass
 
%%
n = 3;
P_correct = [4 0 -3 0];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
     4     0    -3     0
6
Pass
 
%%
n = 4;
P_correct = [8 0 -8 0 1];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
     8     0    -8     0     1
7
Pass
 
%%
n = 5;
P_correct = [16 0 -20 0 5 0];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
    16     0   -20     0     5     0
8
Pass
 
%%
n = 6;
P_correct = [32 0 -48 0 18 0 -1];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
    32     0   -48     0    18     0    -1
9
Pass
 
%%
n = 7;
P_correct = [64 0 -112 0 56 0 -7 0];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
    64     0  -112     0    56     0    -7     0
10
Pass
 
%%
n = 8;
P_correct = [128 0 -256 0 160 0 -32 0 1];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
   128     0  -256     0   160     0   -32     0     1
11
Pass
 
%%
n = 9;
P_correct = [256 0 -576 0 432 0 -120 0 9 0];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
   256     0  -576     0   432     0  -120     0     9     0
12
Pass
 
%%
n = 10;
P_correct = [512 0 -1280 0 1120 0 -400 0 50 0 -1];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
  Columns 1 through 8
         512           0       -1280           0        1120           0        -400           0
  Columns 9 through 11
          50           0          -1
13
Pass
 
%%
n = 11;
P_correct = [1024 0 -2816 0 2816 0 -1232 0 220 0 -11 0];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
  Columns 1 through 8
        1024           0       -2816           0        2816           0       -1232           0
  Columns 9 through 12
         220           0         -11           0
14
Pass
 
%%
n = 12;
P_correct = [2048 0 -6144 0 6912 0 -3584 0 840 0 -72 0 1];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
  Columns 1 through 8
        2048           0       -6144           0        6912           0       -3584           0
  Columns 9 through 13
         840           0         -72           0           1
15
Pass
 
%%
n = 13;
P_correct = [4096 0 -13312 0 16640 0 -9984 0 2912 0 -364 0 13 0];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
  Columns 1 through 8
        4096           0      -13312           0       16640           0       -9984           0
  Columns 9 through 14
        2912           0        -364           0          13           0
16
Pass
 
%%
n = 14;
P_correct = [8192 0 -28672 0 39424 0 -26880 0 9408 0 -1568 0 98 0 -1];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
  Columns 1 through 8
        8192           0      -28672           0       39424           0      -26880           0
  Columns 9 through 15
        9408           0       -1568           0          98           0          -1
17
Pass
 
%%
n = 15;
P_correct = [16384 0 -61440 0 92160 0 -70400 0 28800 0 -6048 0 560 0 -15 0];
assert(isequal(chebyshev1stKindPoly(n),P_correct));
ans =
  Columns 1 through 8
       16384           0      -61440           0       92160           0      -70400           0
  Columns 9 through 16
       28800           0       -6048           0         560           0         -15           0