50 50 40 40 Petrol Best Fit Weighted CO2 Emmisions Diesel Petrol Diesel Best Fit 30 50 о ° 8 о 20 20 о 0 0 CO2 Weighted Percentage 10 0 о -10 0 10 20 30 50 60 50 40 40 Car Position
50 50 40 40 Petrol Best Fit Weighted CO2 Emmisions Diesel Petrol Diesel Best Fit 30 50 о ° 8 о 20 20 о 0 0 CO2 Weighted Percentage 10 0 о -10 0 10 20 30 50 60 50 40 40 Car Position
Refrigeration and Air Conditioning Technology (MindTap Course List)
8th Edition
ISBN:9781305578296
Author:John Tomczyk, Eugene Silberstein, Bill Whitman, Bill Johnson
Publisher:John Tomczyk, Eugene Silberstein, Bill Whitman, Bill Johnson
Chapter39: Residential Energy Auditing
Section: Chapter Questions
Problem 15RQ: When performing a combustion efficiency test, digital flue gas will measure what four...
Related questions
Question
Hello I’m trying to make the graph that you see in the picture but I am having trouble on make the two lines that you see on the graph to over lap each other, I don’t want the two lines to be separate I want the two lines on top of eachother like you see in the picture please fix the code so that the Diesel line is on top of the Petrol line as seen on the picture.
% Sample data for Diesel and Petrol cars
carPosition = linspace(1, 60, 50); % Assumed positions of cars
% Fix the random seed for reproducibility
rng(45);
% Assumed positions of cars
CO2Diesel = 25 + 5*cos(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Diesel
CO2Petrol = 20 + 5*sin(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Petrol
% Fit polynomial curves
pDiesel = polyfit(carPosition, CO2Diesel, 3);
pPetrol = polyfit(carPosition, CO2Petrol, 3);
% Generate points for best fit lines
fitDiesel = polyval(pDiesel, carPosition);
fitPetrol = polyval(pPetrol, carPosition);
% Plotting the data
figure;
hold on;
% Diesel data
scatter(carPosition, CO2Diesel, 'o', 'MarkerEdgeColor', [1 0.5 0]);
% Petrol data
scatter(carPosition, CO2Petrol, 'o', 'MarkerEdgeColor', [0 0.5 1]);
% Diesel best fit
plot(carPosition, fitDiesel, 'Color', [1 0.5 0], 'LineWidth', 2);
% Petrol best fit
plot(carPosition, fitPetrol, 'Color', [0 0.5 1], 'LineWidth', 2);
% Customize the plot
xlabel('Car Position');
ylabel('CO2 Weighted Percentage');
title('Weighted CO2 Emissions');
legend('Diesel', 'Petrol', 'Diesel Best Fit', 'Petrol Best Fit');
grid on;
% Adjust axis limits to match the provided image
xlim([1 60]);
ylim([15 35]);
hold off;
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
Refrigeration and Air Conditioning Technology (Mi…
Mechanical Engineering
ISBN:
9781305578296
Author:
John Tomczyk, Eugene Silberstein, Bill Whitman, Bill Johnson
Publisher:
Cengage Learning
Refrigeration and Air Conditioning Technology (Mi…
Mechanical Engineering
ISBN:
9781305578296
Author:
John Tomczyk, Eugene Silberstein, Bill Whitman, Bill Johnson
Publisher:
Cengage Learning