Question: So everytime i run this code i keep getting different graphs that comes up but the graph that i want to be permanent is this

So everytime i run this code i keep getting different graphs that comes up but the graph that i want to be permanent is this graph. So my request is to please use this code and change it to get the graph that you see in the picture. Also for the lines keep the same lines but could ypu please make the orange line to stop at 30 and you can leave the blue line stop at 40.
Use matlab to fix this code please.
% Sample data for Diesel and PetrolcarPosition = linspace(6,40,50); % Assumed positions of carsCO2Diesel =25+5*cos(carPosition/60*2*pi)+ randn(1,50)*5; % Random data for DieselCO2Petrol =20+5*sin(carPosition/60*2*pi)+ randn(1,50)*5; % Random data for Petrol% Fit polynomial curvespDiesel = polyfit(carPosition, CO2Diesel, 3);pPetrol = polyfit(carPosition, CO2Petrol, 3);% Generate points for best fit linesfitDiesel = polyval(pDiesel, carPosition);fitPetrol = polyval(pPetrol, carPosition);% Plotting the datafigure;hold on;scatter(carPosition, CO2Diesel, 'o', 'MarkerEdgeColor', [10.50]); % Diesel datascatter(carPosition, CO2Petrol, 'o', 'MarkerEdgeColor', [00.51]); % Petrol dataplot(carPosition, fitDiesel, 'Color', [10.50], 'LineWidth', 2); % Diesel best fitplot(carPosition, fitPetrol, 'Color', [00.51], 'LineWidth', 2); % Petrol best fit% Customize the plotxlabel('Car Position');ylabel('CO2 Weighted Percentage');title('Weighted CO2 Emissions');legend('Diesel', 'Petrol', 'Diesel Best Fit', 'Petrol Best Fit');grid on;hold off;
 So everytime i run this code i keep getting different graphs

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!