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 at 17:05
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 Solvers6870
Suggested Problems
-
We love vectorized solutions. Problem 1 : remove the row average.
838 Solvers
-
833 Solvers
-
Celsius to Fahrenheit converter
637 Solvers
-
576 Solvers
-
Calculate Amount of Cake Frosting
26576 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!