Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please explain what is going on in each part of this code Thats on matlab % % Part 2 : Imported Data % Step 1
Please explain what is going on in each part of this code Thats on matlab
Part : Imported Data Step : Import the two datasets and combine them into one global datasetdata readtableCarsAggregated.csv; Import the first datasetdata readtableVansAggregated.csv; Import the second dataset Set a fixed seed for reproducibilityseed ;rngseed; Sample data for Diesel and Petrol carscarPosition linspace; Assumed CO emissions for Diesel and Petrol with modified randomness for spreadCODiesel expcarPosition pi randn; Increased randomness scaleCOPetrol carPosition pi randn; Increased randomness scale Fit polynomial curves with a reduced degree of pDiesel polyfitcarPosition CODiesel, ;pPetrol polyfitcarPosition COPetrol, ; Generate points for best fit linesfitDiesel polyvalpDiesel carPositioncarPosition;fitPetrol polyvalpPetrol carPosition; Plotting the datafigure; hold on; Plot Diesel best fit lineplotcarPositioncarPosition fitDiesel, 'Color', 'LineWidth', ; Plot Petrol best fit lineplotcarPosition fitPetrol, 'Color', 'LineWidth', ; Petrol datascattercarPosition COPetrol, o 'MarkerEdgeColor', ; Diesel datascattercarPosition CODiesel, o 'MarkerEdgeColor', ; Customize the plotxlabelCar Position';ylabelCO Weighted Percentage';titleWeighted CO Emissions';xlim;ylim;yticks::; Setting Yticks to increment by slegendDiesel Best Fit', 'Petrol Best Fit', 'Petrol', 'Diesel';grid on;hold off; Plot the bar chartfigure;bar:numelfueltypes fuelcounts;titleNumber of Cars Using Distinct Fuel Types';xlabelFuel Type';ylabelNumber of Cars';xticks:numelfueltypes;xticklabelsfueltypes; Step b: Create a scatter plot showing the weighted CO Percentage for each carsortedmanufacturers, manufacturerindices sortcombineddata.Manufacturer; Sort manufacturers alphabeticallysortedCOpercentage combineddata.COPercentagemanufacturerindices; Sort CO Percentage accordinglySet a fixed seed for reproducibilityseed ; Choose any integer value for the seedrngseed; Set the random number generator seed Sample data for Diesel and Petrol carscarPosition linspace; Assumed CO emissions for Diesel and PetrolCODiesel expcarPosition pi randn;COPetrol carPosition pi randn; Fit polynomial curves with a reduced degree of pDiesel polyfitcarPosition CODiesel, ;pPetrol polyfitcarPosition COPetrol, ; Generate points for best fit linesfitDiesel polyvalpDiesel carPositioncarPosition;fitPetrol polyvalpPetrol carPosition; Plotting the datafigure;hold on
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started