50 Weighted CO2 Emmisions 50 Diesel Petrol 10 40 30 CO2 Weighted Percentage 20 8 10 0 о о 800 0 0 о % -10 0 ୦୧ о 10 10 20 30 40 40 50 60 Car Position Diesel Best Fit Petrol Best Fit
50 Weighted CO2 Emmisions 50 Diesel Petrol 10 40 30 CO2 Weighted Percentage 20 8 10 0 о о 800 0 0 о % -10 0 ୦୧ о 10 10 20 30 40 40 50 60 Car Position Diesel Best Fit Petrol Best Fit
Elements Of Electromagnetics
7th Edition
ISBN:9780190698614
Author:Sadiku, Matthew N. O.
Publisher:Sadiku, Matthew N. O.
ChapterMA: Math Assessment
Section: Chapter Questions
Problem 1.1MA
Related questions
Question
Hi I need help to make the line change into a different color, I half of the line to be orange and I need the other half of the line towards the end to be purple as shown in the picture. Also I need there be a box saying Diesel, petrol, diesel best fit, petrol best fit. This part is also shown in the graph.
Please use this code and fix it in MATLAB:
% Sample data for Diesel and Petrol cars
carPosition = linspace(1, 60, 50); % Assumed positions of cars
% Fix the random seed for reproducibility
rng(50);
% 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);
% Combine the best fit lines
combinedFit = (fitDiesel + fitPetrol) / 2;
% Plotting the data
figure; hold on;
% Combined best fit line
plot(carPosition, combinedFit, 'Color', 'k', 'LineWidth', 2);
% Petrol data
scatter(carPosition, CO2Petrol, 'o', 'MarkerEdgeColor', [0 0.5 1]);
% Diesel data
scatter(carPosition, CO2Diesel, 'o', 'MarkerEdgeColor', [1 0.5 0]);
% Customize the plot
xlabel('Car Position');
ylabel('CO2 Weighted Percentage');
title('Weighted CO2 Emissions');
legend('Combined Best Fit', 'Petrol', 'Diesel');
grid on;
% Adjust axis limits to match the provided image
xlim([1 60]);
ylim([15 35]);
hold off;
![50
Weighted CO2 Emmisions
50
Diesel
Petrol
10
40
30
CO2 Weighted Percentage
20
8
10
0
о
о
800
0 0
о
%
-10
0
୦୧
о
10
10
20
30
40
40
50
60
Car Position
Diesel Best Fit
Petrol Best Fit](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F8547315f-a2b1-4fb3-8610-7db5d0a7d9a2%2Fb1d48436-b3ef-4d9a-bc93-f4f6eb4d0f9b%2Fowit5o6_processed.jpeg&w=3840&q=75)
Transcribed Image Text:50
Weighted CO2 Emmisions
50
Diesel
Petrol
10
40
30
CO2 Weighted Percentage
20
8
10
0
о
о
800
0 0
о
%
-10
0
୦୧
о
10
10
20
30
40
40
50
60
Car Position
Diesel Best Fit
Petrol Best Fit
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
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 with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Elements Of Electromagnetics](https://www.bartleby.com/isbn_cover_images/9780190698614/9780190698614_smallCoverImage.gif)
Elements Of Electromagnetics
Mechanical Engineering
ISBN:
9780190698614
Author:
Sadiku, Matthew N. O.
Publisher:
Oxford University Press
![Mechanics of Materials (10th Edition)](https://www.bartleby.com/isbn_cover_images/9780134319650/9780134319650_smallCoverImage.gif)
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:
9780134319650
Author:
Russell C. Hibbeler
Publisher:
PEARSON
![Thermodynamics: An Engineering Approach](https://www.bartleby.com/isbn_cover_images/9781259822674/9781259822674_smallCoverImage.gif)
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:
9781259822674
Author:
Yunus A. Cengel Dr., Michael A. Boles
Publisher:
McGraw-Hill Education
![Elements Of Electromagnetics](https://www.bartleby.com/isbn_cover_images/9780190698614/9780190698614_smallCoverImage.gif)
Elements Of Electromagnetics
Mechanical Engineering
ISBN:
9780190698614
Author:
Sadiku, Matthew N. O.
Publisher:
Oxford University Press
![Mechanics of Materials (10th Edition)](https://www.bartleby.com/isbn_cover_images/9780134319650/9780134319650_smallCoverImage.gif)
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:
9780134319650
Author:
Russell C. Hibbeler
Publisher:
PEARSON
![Thermodynamics: An Engineering Approach](https://www.bartleby.com/isbn_cover_images/9781259822674/9781259822674_smallCoverImage.gif)
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:
9781259822674
Author:
Yunus A. Cengel Dr., Michael A. Boles
Publisher:
McGraw-Hill Education
![Control Systems Engineering](https://www.bartleby.com/isbn_cover_images/9781118170519/9781118170519_smallCoverImage.gif)
Control Systems Engineering
Mechanical Engineering
ISBN:
9781118170519
Author:
Norman S. Nise
Publisher:
WILEY
![Mechanics of Materials (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337093347/9781337093347_smallCoverImage.gif)
Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:
9781337093347
Author:
Barry J. Goodno, James M. Gere
Publisher:
Cengage Learning
![Engineering Mechanics: Statics](https://www.bartleby.com/isbn_cover_images/9781118807330/9781118807330_smallCoverImage.gif)
Engineering Mechanics: Statics
Mechanical Engineering
ISBN:
9781118807330
Author:
James L. Meriam, L. G. Kraige, J. N. Bolton
Publisher:
WILEY