Cody

Solution 2525699

Submitted on 12 Jun 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
x = 1:100; y_correct = 2:2:200; [fh, pars] = generateFit(x, y_correct); y = fh(pars, x); assert( isequal(y,y_correct) )

Undefined function 'generateFit' for input arguments of type 'double'. Error in Test1 (line 3) [fh, pars] = generateFit(x, y_correct);

2   Fail
x = 1:100; y_correct = 101:200; [fh, pars] = generateFit(x, y_correct); y = fh(pars, x); assert( isequal(y,y_correct) )

Undefined function 'generateFit' for input arguments of type 'double'. Error in Test2 (line 3) [fh, pars] = generateFit(x, y_correct);

3   Fail
x = 1:100; y_correct = 102:2:300; [fh, pars] = generateFit(x, y_correct); y = fh(pars, x); assert( isequal(y,y_correct) )

Undefined function 'generateFit' for input arguments of type 'double'. Error in Test3 (line 3) [fh, pars] = generateFit(x, y_correct);

4   Fail
x = 1:100; y_correct = 102:2:300; [fh, pars] = generateFit(x, y_correct); els = 10+randi(30) : 60+randi(30); y = fh(pars, x(els)); assert( isequal(y,y_correct(els)) ) y = fh(pars, x+100); assert( isequal(y,302:2:500) )

Undefined function 'generateFit' for input arguments of type 'double'. Error in Test4 (line 3) [fh, pars] = generateFit(x, y_correct);

5   Fail
x = 1000:-1:500; y_correct = 0:500; [fh, pars] = generateFit(x, y_correct); y = fh(pars, x); assert( isequal(y,y_correct) )

Undefined function 'generateFit' for input arguments of type 'double'. Error in Test5 (line 3) [fh, pars] = generateFit(x, y_correct);

6   Fail
x = 1000:-1:500; y_correct = -500:2:500; [fh, pars] = generateFit(x, y_correct); y = fh(pars, x); assert( isequal(y,y_correct) )

Undefined function 'generateFit' for input arguments of type 'double'. Error in Test6 (line 3) [fh, pars] = generateFit(x, y_correct);

7   Fail
for i = 1 : 20 x = -randi(1000) : randi(10) : randi(1000); m = randi(20)-10; c = randi(20)-10; y_correct = round(exp(log(c) + log(x))) - m^1 * (x(1))^0; [fh, pars] = generateFit(x, y_correct); y = fh(pars, x); assert( isequal(y,y_correct) ) end;

Undefined function 'generateFit' for input arguments of type 'double'. Error in Test7 (line 6) [fh, pars] = generateFit(x, y_correct);

8   Fail
% "Gradient and intercept" x1 = 1:100; y1_correct = 102:2:300; [fh1, pars1] = generateFit(x1, y1_correct); % "Another gradient and intercept" x2 = 1000:-1:500; y2_correct = 0:500; [fh2, pars2] = generateFit(x2, y2_correct); % According to the Problem Statament, fh1 and fh2 should be interchangeable. y1 = fh2(pars1, x1); assert( isequal(y1,y1_correct) ) y2 = fh1(pars2, x2); assert( isequal(y2,y2_correct) )

Undefined function 'generateFit' for input arguments of type 'double'. Error in Test8 (line 4) [fh1, pars1] = generateFit(x1, y1_correct);

9   Fail
% Finally, check that the user is sending a small number of parameters to their % custom function (to be called via the function handle), and not simply sending % the entire vector y. x = 1:1000; y_correct = flip(1:1000); [fh, pars] = generateFit(x, y_correct); pw = whos('pars') assert( pw.bytes < 100 , 'Parameter variable is too big.') y = fh(pars, x); assert( isequal(y,y_correct) )

Undefined function 'generateFit' for input arguments of type 'double'. Error in Test9 (line 6) [fh, pars] = generateFit(x, y_correct);