Cody

Solution 2226463

Submitted on 21 Apr 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
N = 5 load(fullfile(matlabroot, 'toolbox/stats/statsdemos', 'carbig.mat')); Model = strtrim(string(Model)); cars = table(Model, MPG, Horsepower, Weight, Acceleration); save cars.mat cars assert(isequal(sort_cars(N),[35; 31; 39.1; 35.1; 31]));

N = 5 cars = struct with fields: cars: [406×5 table]

Error using matlab.internal.math.sortrowsParseInputs Column sorting vector must contain integers with absolute value between 1 and the number of columns in the first argument. Error in sortrows (line 64) [col, nanflag, compareflag] = matlab.internal.math.sortrowsParseInputs(ismatrix(A),size(A,2),A,varargin{:}); Error in sort_cars (line 3) B = sortrows(cars,2) Error in Test1 (line 6) assert(isequal(sort_cars(N),[35; 31; 39.1; 35.1; 31]));

2   Fail
N = 6 load(fullfile(matlabroot, 'toolbox/stats/statsdemos', 'carsmall.mat')); Model = strtrim(string(Model)); cars = table(Model, MPG, Horsepower, Weight, Acceleration); save cars.mat cars assert(isequal(sort_cars(N),[33; 29.5; 26; 29; 38; 32]));

N = 6 cars = struct with fields: cars: [100×5 table]

Error using matlab.internal.math.sortrowsParseInputs Column sorting vector must contain integers with absolute value between 1 and the number of columns in the first argument. Error in sortrows (line 64) [col, nanflag, compareflag] = matlab.internal.math.sortrowsParseInputs(ismatrix(A),size(A,2),A,varargin{:}); Error in sort_cars (line 3) B = sortrows(cars,2) Error in Test2 (line 6) assert(isequal(sort_cars(N),[33; 29.5; 26; 29; 38; 32]));