Problem 44952. Find MPG of Lightest Cars
The file cars.mat contains a table named cars with variables Model, MPG, Horsepower, Weight, and Acceleration for several classic cars.
Load the MAT-file. Given an integer N, calculate the output variable mpg.
Output mpg should contain the MPG of the top N lightest cars (by Weight) in a column vector.
Solution Stats
Problem Comments
-
40 Comments
Show
37 older comments
梓斌
on 22 Nov 2024
Notes:
1.In the function, you need write this code "load cars.mat;". Then, you have a table variable:cars
2.The return values mpg is a double variable, not table variable.
Xinghang
on 19 Jan 2025
should understand the use of table.
El
on 26 Apr 2025
Keep in mind that when you load cars.. you'll need to extract the table from what you loaded...
i.e.
cars = load('cars.mat');
cars = cars.cars;
Solution Comments
Show commentsProblem Recent Solvers7141
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
51598 Solvers
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15681 Solvers
-
Find state names that start with the letter N
1369 Solvers
-
Longest run of consecutive numbers
6159 Solvers
-
2180 Solvers
More from this Author13
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!