Question: MATLAB PROJECT: ENES 101 MATLAB Project Description `Spring 2021 Background: As some of you might know, Talal is an avid bike rider. Since the COVID-19
MATLAB PROJECT:
ENES 101 MATLAB Project Description `Spring 2021
Background: As some of you might know, Talal is an avid bike rider. Since the COVID-19 lockdown, most of his riding has been on an indoor trainer coupled to the online app Zwift. This project applies our MATLAB and data analysis skills to actual data collected his Zwift rides from March 30, 2021 to December 31, 2021.
The MATLAB script GetRideDataS21, which will be provided on Blackboard, creates six arrays of data: DayOfYear, DecimalMinutes, DistanceMiles, Calories, SpeedMPH,climb,and cadence. The respective units are an integer count, time in minutes, with 20.5 = 20:30, distance in miles, kcal (dietary Calories), miles per hour, feet, and strokes per minute. Download this script into your MATLAB directory. Use these arrays as instructed in the various sections of the Assignment.
All submissions should be in PDF format via the Blackboard Assignment facility.
All questions posed in the various parts of the assignment should be answered by output of text in the command window.
Assignment: This assignment has four parts due at different times.
Part 1: Create Useful Functions
Due: Monday, March 22, unless changed in class and on Blackboard Credit: One Homework Assignment: Do this assignment after reading zyBooks Chapter 3. Create the following functions in MATLAB and save them to your directory. You must use the function names provided below! Use the attached test script TestConversionsS21.m to test your functions.
kmout = MilesToKm(miles) % converts a value in miles to kilometers
kJoulesOut = CalTokJoules(DietaryCalories) % converts dietary calories (big calories) to kiloJoules (10^3 Joules = 1 kJ)
kWhrOut = KJoulesToKWHr(Kjoules) % converts kJoules to kilowatt hours metersout = FeetTokm(feet) % converts feet to
kilometers secondsout = HoursToSeconds(hours) % converts hours to seconds
Each of the functions must follow good programming practices, including appropriate help comments that will respond to MATLABs help command.
Submission: ExecutethetestscriptTestConversionsS21. PublishTestConversionsS21, its outputs, and each of your m-files to PDF form and submit them per the instructions received in discussion. A single output PDF containing all of the information is preferred, but separate files will be accepted.
The publish command is executed in the MATLAB command window, and looks like this: >> publish(
DO NOT include the < or > when you use publish. For example, here is a publish command that Talal used recently in another class:
>> publish('CMPE323_F19_Lab0_solution','pdf') The resultant PDF file will show up in a folder named HTML in your current MATLAB directory.
.Test conversion For part 1:
%TestConversions
% Test Script for S21 ENES101 MATLAB conversion mini-project
% EFCL 2/25/2019 revised and corrected 3/3/2019
% Revision 2 3/5/2019
%
%Revised for F19 10/1/19 EFCL
%Revised for S20 3/3/19 EFCL
%Revised for S20 3/4/19 JEB
%Revised for S21 2/24/21 JEB
close all % close existing figures
clear % clear the workspace
clc
std_input = [1 10 0.05 50]; %range of inputs for all functions
% Test MilesToKm
%
% Don't assume that student wrote the function to handle input arrays
km_out=zeros(1,length(std_input));
for k = 1:length(std_input)
km_out(k) = MilesToKm(std_input(k)); % just the k-th value
disp(['A value of ',num2str(std_input(k)),' miles is ',num2str(km_out(k)),' km']);
end
km_out_result = std_input*1.609; % standard solution
error = km_out - km_out_result;
disp(['For MilesToKm, the sum squared error = ',num2str(sum(error.^2))]);
disp(' ');
% Test CalToJoules
%
% Don't assume that student wrote the function to handle input arrays
kJ_out=zeros(1,length(std_input));
for k = 1:length(std_input)
kJ_out(k) = CalTokJoules(std_input(k)); % just the k-th value
disp(['A value of ',num2str(std_input(k)),' (dietary) Calories is ',num2str(kJ_out(k)),' kJ']);
end
kJ_out_result = std_input*4.184; % standard solution
error = kJ_out - kJ_out_result;
disp(['For CalTokJoules, the sum squared error = ',num2str(sum(error.^2))]);
disp(' ');
% Test KJoulestoKWHr
%
% Don't assume that student wrote the function to handle input arrays
KWHr_out=zeros(1,length(std_input));
for k = 1:length(std_input)
KWHr_out(k)= KJoulesToKWHr(std_input(k)); % just the k-th value
disp(['A value of ',num2str(std_input(k)),' KJoules is ',num2str(KWHr_out(k)),' KWHr']);
end
KWHr_out_result = std_input/3600; % standard solution
error = KWHr_out - KWHr_out_result;
disp(['For KJoulesToKWHr, the sum squared error = ',num2str(sum(error.^2))]);
disp(' ');
%Test HoursToSeconds
% Don't assume that student wrote the function to handle input arrays
sec_out =zeros(1,length(std_input));
for k = 1:length(std_input)
sec_out(k) = HoursToSeconds(std_input(k));
disp(['A value of ',num2str(std_input(k)),' hours converts to ',num2str(sec_out(k)),' seconds']);
end
sec_out_result = std_input*3600;
error = sec_out - sec_out_result;
disp(['For HoursToSeconds, the sum squared error = ',num2str(sum(error.^2))]);
disp(' ');
UNPACK HISTO GRAM:
function [Values,NumBins,binCenters]=unpackHistogram(hgram);
%function [Values,NumBins,binCenters]=unpackHistogram(hgram)
% This function unpacks the data structure provided by the MATLAB function
% histogram into simple arrays that can be used for further processing.
% By using this function, the user does not need to understand the
% underlying structure of the histogram object, and, in fact, doesn't need
% to know anything about structures at all.
%
% Calling Parameters
% hgram: a histogram structure created by calling the MATLAB function
% HISTOGRAM with any of its scaling options.
%
% Returned parameters
% Values: a one dimensional array containing the value in each bin of
% the histogram. If the histogram is unscaled, then this is the
% number of counts that occurred in each bin.
%
% NumBins: number of bins in the histogram, as determined by the
% MATLAB function HISTOGRAM
%
% binCenters: center values of the bins used by HISTOGRAM
%
% Usage: An unscaled histogram consisting of the count of the number of
% data samples in each bin is created by
%
% hgram = histogram(data)
%
% The data may then be unpacked using this function
%
% [Values, NumBins, binCenters] = unpackHistogram(hgram);
%
% This function DOES NOT WORK with the "old" MATLAB hist() function.
%
% EFCL 2/27/2021
%
Values = hgram.Values;
NumBins = hgram.NumBins;
BinEdges = hgram.BinEdges;
BinWidth = hgram.BinWidth;
binCenters = BinEdges+BinWidth/2;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
