Cody

Problem 44952. Find MPG of Lightest Cars

Solution 3865613

Submitted on 26 Nov 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

Error using tabular/sortrows (line 57) Unrecognized table variable name 'weight'. Variable names are case sensitive. You may have intended to access the 'Weight' variable. Error in sort_cars (line 4) cars = sortrows(cars,'weight') 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

Error using tabular/sortrows (line 57) Unrecognized table variable name 'weight'. Variable names are case sensitive. You may have intended to access the 'Weight' variable. Error in sort_cars (line 4) cars = sortrows(cars,'weight') Error in Test2 (line 6) assert(isequal(sort_cars(N),[33; 29.5; 26; 29; 38; 32]));

Suggested Problems

More from this Author13

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!