Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me with this MATLAB problem. Thank you in advance! I just bought a n

ID: 3887876 • Letter: P

Question

Please help me with this MATLAB problem. Thank you in advance!

I just bought a new BMW 535i Touring. The advertised gas mileage for this car is 29 miles per gallon (mpg). Obviously this will decrease beyond certain driving speeds. I like to drive fast on the Autobahn, but I can’t stand the idea of getting less than 15 mpg. The file mpg.m on Canvas takes velocity as an input and returns the mpg of my new car at this velocity. Write a script file called bmw.m to determine how fast I can drive without dropping below 15 mpg. Start at 45 mph, and increase velocity by 0.1 mph every time through a while loop.

Explanation / Answer

Please provide the code for mpg.m file which will provide the mileage as output when we provide velovity as input;

Below is the algorithm for the given problem :

set velocity to 45

start an infinite loop

mileage = mpg(velocity)

check if mileage <= 15

break

increment velocity by 0.1

end loop

print the velocity as the maximum velocity at which one can drive the car without dropping the mileage below 15 mph.

Code :

velocity=45;
while 1 == 1 %infinite loop
mileage = mpg(velocity); %calculating mileage
if mileage<15
break;
end
velocity += 0.1; %inreasing velocity
end
fprintf('Max Velocity : %1.2f ',velocity)

Please provide the required details for code output.

Please let me know if you face any isue while executing the code.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote