Use the data from the points to calculate the length of the line between them. I
ID: 3675848 • Letter: U
Question
Use the data from the points to calculate the length of the line between them. In recent years, the price of gasoline I companies have responded with more fuel-efficient hybrid models. But will you save money by purchasing a hybrid such as the Toyota Camry rather than a Camry with a standard engine? The hybrid vehicles are considerably more expensive, but get better gas mileage. Consider the vehicle prices and gas efficiencies shown in Table P7.17. One way to compare two vehicles is to find the "cost to own."Cost to own = Purchase cost + Upkeep + Gasoline cost Assume for this exercise that the upkeep costs are the same, so in our comparison we'll set them equal to zero. What do you think the cost of gasoline will be over the next several years? Prompt the user to enter an estimate of gasoline cost in dollars/ gallon. Find the "cost to own" as a function of the number of miles driven for a pair of vehicles from the table, based on the fuel price estimate front part a. Plot your results on an x-y graph. The point where the two lines cross is the break-even point. Use the ginput function to pick the break-even point off the graph. Use sprintf to create a siring identifying the breakeven point, and list' the result to create a text-box annotation on your graph. Position the text box using the gtext function.Explanation / Answer
%reading gasoline cost from user
userGasolineCost = input('Enter future estimated gasoline Cost: ')
t = 18000:1000:26000
y = userGasolineCost+18720 %toyato sample camry
y2 = userGasolineCost+25350 %toyato camro hybrid
[xout,yout] = ginput(2);
%plotting graph
plot(t,y,'linewidth',2)
set(gca,'xlim',[min(t) max(t)],'ylim',[-1.1 1.1])
hold on
plot(t,y2,'g','linewidth',2)
plot(xout,yout,'r.','markersize',18)
res = sprintf('%d %d',xout,yout)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.