M3_Decision Structures
.pdf
keyboard_arrow_up
School
University of California, Los Angeles *
*We aren’t endorsed by this school
Course
331
Subject
Mechanical Engineering
Date
Dec 6, 2023
Type
Pages
5
Uploaded by EarlMetalLion28
1
Assignment M-3_ Matlab Decision Structures (Individual, 30 points)
Overall Purpose
This assignment introduces you to the use of decision or conditional structures. These structures
allow you to select values that meet a stated condition, and employ relational operators in
if-
else-end, if-elseif-else-end
and other combinations of statements. These statements
test a Boolean expression, then determine what action to take, depending on
the
true
or
false
result.
You will write and run a separate Matlab script for each of the following problems.
Description
Solve each of the following problems by writing and running Matlab scripts.
Interpret the
results for each problem, and answer the questions in Problem 2.
Please include the following for each problem:
1.
A brief statement explaining the problem (1-2 sentences)
2.
The listing of your code (copy and paste your script into your word processor with
the source formatting). Please be sure to enter a sufficient number of comments for
each major block of the code.
3.
A screen capture of each requested
sample run
with the requested values, showing
the command window and the workspace. These must be legible.
4.
Please create one pdf file to include all of the information from #1 through #4 for both
problems.
5.
Hints for more efficient programming:
a.
Choose descriptive variable names. Names like MainMass and AlbumSales are
easier for others to understand than x, y, z, etc.
b.
The “Snipping Tool” or “Snip & Sketch” (use your Windows search bar to find
it) are good ways to create readable screenshots.
c.
Use clear and clc commands at the beginning of your program to clear the
workspace and the command window priori to running your program.
Problem 1: WAR Calculator
After getting to know your randomly assigned suitemates, you realize they are all big baseball
fans. They decide that a good way of bonding would be to start a fantasy baseball league
together. Unfortunately for you, baseball is not your sport. Since you don’t know much about it,
you decide to make a code that will decipher some statistics for you so you can still pick good
players. You build a code that sorts players based on their Wins Above Replacement (WAR)
score.
Your program should:
○
Request that the user input a player’s WAR score
2
○
Use a conditional structure to determine the value of the player based on their WAR, with
ranges given in the table on the next page:
WAR
Quality
< 1
Scrub
>= 1 & < 2
Role player
>= 2 & < 3
Solid starter
>= 3 & < 4
Good
player
>= 4 & < 5
All Star
>= 5 & < 6
Superstar
>= 6
MVP
○
Given the user-inputted WAR score, have the program print the player’s quality as a full
sentence using the
fprintf
command (See Week 10A and 10B slide set for examples
of
fprintf
syntax)
Run the program and take Command Window screenshots of the results for WAR scores of 2.7
and 5.1, respectively.
Please note that these values should be entered in the command window
when you run the program, and should not be hard-coded into the program itself.
Problem 2: Methane Sensor
Methane gas is an explosion risk at or above a 5% concentration. You are developing a mine
ventilation mechanism to maintain safe levels of methane into a space into which the gas often
leaks. Create a Matlab program that will take a concentration of methane in parts per million
(ppm), and determine the appropriate air ventilation rate in m
3
/s.
Your program should:
1.
Ask the user to input a methane concentration in ppm
2.
Use a conditional structure to determine a ventilation rate, using the following table:
3
Concentration
(ppm)
Ventilation Rate
(m
3
/s)
0 =< ppm < 5000
5
5000 =< ppm <
20000
10
20000 =< ppm <
40000
20
40000 =< ppm <
50000
40
50000 =< ppm
80
3.
Using the fprintf command, output the required ventilation rate. Do not forget to specify
that the output number is the ventilation rate and that its units are m
3
/sec.
4.
Issue an emergency evacuation warning if the methane levels indicate an explosion risk
(>=50000 ppm). Use a short phrase, such as DANGER! or LEAVE NOW!
Create sample runs for 25000 ppm and 65000 ppm (should return 20 and 80 m
3
/s, respectively).
Deliverables for this assignment:
1.
.m file for Problem 1, named as M3_Problem1_YourPID.m
2.
.m file for Problem 2, named as M3_Problem2_YourPID.m
3.
A single .pdf file with an appropriate file name, containing:
Your name, class section, etc.
For each problem, a brief statement explaining the problem (1-2 sentences)
The listing of your code (copy and paste your script into your word processor
with the source formatting, i.e., such that the color and font formatting of the
pasted code is the same as it appears in Matlab).
A screen capture of each requested sample run with the requested values,
showing the command window and workspace. These must be legible.
File naming convention: YourPID_M3_summary.pdf
Rubric
The rubric for this assignment is given on the next two pages.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Could you please fix my code it’s supposed to look like the graph that’s on the picture. But the lines do not cross eachother at the beginning. Could you make the lines look like the lines on the graph?
Use this code in MATLAB and fix it.
% Sample data for Diesel and Petrol cars
carPosition = linspace(1, 60, 50); % Assumed positions of cars
% Define your seed here
seed = 50;
rand('seed',seed); % Set the seed for reproducibility
% Assumed CO2 emissions for Diesel and Petrol
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 with a reduced degree of 2
pDiesel = polyfit(carPosition, CO2Diesel, 2);
pPetrol = polyfit(carPosition, CO2Petrol, 2);
% Generate points for best fit lines
fitDiesel = polyval(pDiesel, carPosition);
fitPetrol = polyval(pPetrol, carPosition);
% Plotting the data
figure;
hold on;
% Plot Diesel best fit line…
arrow_forward
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 =…
arrow_forward
please write a matlab code
arrow_forward
Motiyo
Add explanation
arrow_forward
MULTIPLE CHOICE -The answer is one of the options below please solve carefully and circle the correct option Please write clear .
arrow_forward
2. There were 42 mangoes in each crate. 12 such crates of mangoes were delivered to a factory. 4 mangoes
were rotten and had to be thrown away. The remaining mangoes were packed into boxes of 10 mangoes
each. Write a numerical expression in MATLAB syntax to represent this situation and then find how many
boxes of mangoes were there?
OFocus
4:20 AM
28°C Mostly clear
3/26/2022
LG
CVENUENS
THANOS
BOBBLEHEAD
AMANLANTE A ON CABIA ANn
POCKET
YOP! AVENGES
KEYCHAIN
INFINITY WAR
Handy Fan
THANOS
BOBBLE HEAD
IGENA ERANLIA P COs CA AN
arrow_forward
I need help with the purple line the line that you see one the graph on the picture needs to be on the graph.
Use this code to add the purple line and make sure it’s crossing the orange line. Please make sure the lines are positioned the same way it is shown on the picture with the graph.
Use this code on MATLAB and add the purple line.
% Sample data for Diesel and Petrol cars
carPosition = linspace(1, 60, 50); % Assumed positions of cars
% Use the 'seed' function instead of 'rng'
seed = 50; % Define your seed here
rand('seed',seed);
% Assumed CO2 emissions for Diesel and Petrol
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 with a reduced degree of 2
pDiesel = polyfit(carPosition, CO2Diesel, 2);
pPetrol = polyfit(carPosition, CO2Petrol, 2);
% Generate points for best fit lines
fitDiesel = polyval(pDiesel, carPosition);…
arrow_forward
Hello I’m trying to make the graph that you see in the picture, I’m trying the exact copy of that graph using this code but I’m having a hard time doing that. Could you change the code so that it looks like the graph that you see on the picture using MATLAB, please send the code when you are finished.
% 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;
scatter(carPosition, CO2Diesel, 'o', 'MarkerEdgeColor', [1 0.5…
arrow_forward
3. (Make a MatLab code) You have invested money in a bank account that
compounds annually. The interest rate is 6.4%. You want to know the balance of
the account after 5 years. Use an initial balance of $1000.
arrow_forward
Scenario
You are assigned a role as a mechanical engineer for a vehicle design manufacturing company. Your
department has a software to perform numerical differentiation and integration. To be able to verify the
results of using the software and validate these results, your department manager has asked you to
analytically perform some tasks to validate the results generated by the software.
Q: is the last two digits of your student Id number. If your number is (20110092) then Q=92.
P: is the last digit of your student Id Number. If your number is (20110092) then P=2,
If that digit equals zero then use P=1. Example: If your number is (20110040) then P=1.
Task 1
Determine the gradient of following functions at the given points:
a) x(t) = (2t7 + P t-2)² + (6vi – 5) when t = 1
5s+7
b) v(s) =
when s = 3
(s²-P)2
c) i(t) = 5(1 – In(2t – 1) )
when t= 1 sec.
d) V(t) =5sin(100nt + 0.2) Volts , find i(t) = 10 × x10-6 dV©)
Ampere when t= 1ms.
dt
e) y(t) = e¬(t-n) sin(Qt + P)
when t = n radian
f)…
arrow_forward
Matlab coding
arrow_forward
Use MATLAB please make code for this.
arrow_forward
I need the answer quickly
arrow_forward
Q4: Create a Visual Basic Project to find the value of the following series:
h? h4 h3
cos(h) = h –
2!
3!
4!
Write the code program so that the value of angle (h) is entered into inputbox.
Estimate the value of series (cos(h)) so that the absolute value of any term is
greater or equal to 10-6. Display the required number of terms (N) which it used in
this series in a text box and display the result of series (cos(h)) in another separate
text box.
arrow_forward
This code keeps on generating graphs with different curves. The picture that you see two different graphs comes from the same code but both of them have different curves. I need the curve to look like the picture that only has one graph. I basically need the line to have a slight curve and every time I run the code it will come up as the same graph every time. Use this code on MATLAB and fix it
% Sample data for Diesel and Petrol cars
carPosition = linspace(1, 60, 50); % Assumed positions of cars
% Use the 'seed' function instead of 'rng'
seed = 50; % Define your seed here
rand('seed',seed);
% Assumed CO2 emissions for Diesel and Petrol
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 with a reduced degree of 2
pDiesel = polyfit(carPosition, CO2Diesel, 2);
pPetrol = polyfit(carPosition, CO2Petrol, 2);
% Generate points for best fit…
arrow_forward
The following tools / resources may be useful for you to complete the assignment:a. Chatgpt (You may use it to learn Matlab coding or any other computer language. An example is given here: https://shareg.pt/mXHGne9 ). Please take note that code generated by chatgpt can be directly copied and pasted.b. Matlabi) Useful cheat sheet (https://n.ethz.ch/~marcokre/download/ML-CheatSheet.pdf)ii) Getting started with Matlab (https://matlabacademy.mathworks.com/en/details/gettingstarted )iii) Getting 30-day Matlab trial license (https://www.mathworks.com/campaigns/products/trials.html ) iv) Polyfit (https://www.mathworks.com/help/matlab/ref/polyfit.html )v) Exponential Fit (https://www.mathworks.com/matlabcentral/answers/91159-how-do-i-fit-an-exponential-curve-to-my-data)c. PlotDigitizer (https://plotdigitizer.sourceforge.net/ ) or a free online app that does not requires installation (https://plotdigitizer.com/app )You may use your own engineering judgement to make any assumptions on any…
arrow_forward
Create an illustration or diagram of the amusement park ride called THE BUMPER CAR RIDE, then proceed to add labels based on the guidelines provided within the image.
The screenshot is the example of the diagram BUT THAT IS A DIAGRAM OF THE GRAVITRON RIDE. I need an illustration DIAGRAM OF THE BUMPER CAR RIDE, do not answer using AI.
arrow_forward
How do I input this code for this MATLAB problem? Thanks!
arrow_forward
Can i get help with these questions
arrow_forward
Please provide the correct matlab code for the following question.
arrow_forward
Learning Goal:
To use transformation equations to calculate the plane state of stress in a rotated coordinate system.
The normal and shear stresses for a state of stress depend on the orientation of the axes. If the stresses are
given in one coordinate system (Figure 1), the equivalent stresses in a rotated coordinate system (Figure 2) can
be calculated using a set of transformation equations. Both sets of stresses describe the same state of stress.
In order to use the transformation equations, a sign convention must be chosen for the normal stresses, shear
stresses, and the rotation angle. For the equations below, a positive normal stress acts outward on a face. A
positive Try acts in the positive y-direction on the face whose outward normal is in the positive x-direction. The
positive direction for the rotation is also shown in the second figure.
The stresses in the rotated coordinate system are given by the following equations:
στ
σy
+
cos 20+Try sin 20
2
2
σετ συ
=
σy'
cos 20-Try…
arrow_forward
4. Documents business requirements use-case narratives.for only one process
note: please i want Documents like this in pic
arrow_forward
There is a small space between the orange and purple line could you please connect the two lines together also can you please make the purple line shorter and then connect the purple line to the orange line, please take out the box that says “Diesel, petrol, Diesel best fit, petrol best fit”. Also when ever I run this code the graph shows up but there are still errors that comes up could you please fix them when you are running this on MATLAB.
Please use this code on MATLAB and fix it.
% 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 CO2 emissions for Diesel and Petrol
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…
arrow_forward
Solve correctly
arrow_forward
PLEASE ANSWER QUICKLY AND FOLLOW THE INSTRUCTION.
USE: A= 0
THANKS
arrow_forward
Help me solve this using MATLAB
arrow_forward
I’m making the graph that you see in the picture but the code that I’m using makes the line with to many curves. Could you make the lines look like the one that you see on the graph. Don’t change the color just make it with a little bit less curves like you see in the picture.
Use this code on MATLAB and fix it.
% 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 CO2 emissions for Diesel and Petrol
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);
% Combined best fit
combinedFit = (fitDiesel + fitPetrol) / 2;…
arrow_forward
Engr 215 Matlab
Fahrenheit to Celsius using multiple statements
Given a Fahrenheit value temperatureFahrenheit, write a statement that assigns temperatureCelsius with the equivalent Celsius value.
While the equation is C = 5/9 * (F - 32), as an exercise use two statements, the first of which is "fractionalMultiplier = 5/9;"]
arrow_forward
I having a problem with my code in MATLAB. In the following code results for r is just a 1x3 matrix. Although inside the while loop r equals to multiple 1x3 matrices. I need r equal to one matrix that is of size 27032x3. So, I just need the multiple r matrices to merge together to get one big matrix. I need that matrix to retain its value outside the while loop as well.
cc=0; % set line counter
JD = 2460626.666667;
fid = fopen('tle_catalog.txt'); % load the TLE
tline2='gg';
while ischar(tline2)
cc = cc+1; % counter
name = fgets(fid);% for the ones with three lines
tline1 = fgets(fid); % collect first line of two line elements
tline2 = fgets(fid); % collect second line of two line elements
if tline2>0 % stop at the end of the file
% initialize the propagation
[satrec, startmfe, stopmfe, deltamin] ...
= twoline2rv(721, tline1, tline2, 'c', 'd');
time_JD = tline1(21:32);
yeardayhour = str2double(regexp(tline1, '(\d{2})(\d{3})(\.\d+)', 'tokens', 'once'));
dn =…
arrow_forward
I’m using this code in MATLAB but for some odd reason every time I run it on MATLAB I keep on getting a different graphs. In the picture that shows two different graphs are from the same code, but I need to it to look like the picture that has one graph. Could you please fix it. To make it look like the picture that has one graph?
Here is the code:
% Sample data for Diesel and Petrol
carPosition = linspace(1, 60, 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);
% Plotting the data
figure;
hold on;
scatter(carPosition, CO2Diesel, 'o', 'MarkerEdgeColor', [1 0.5 0]); % Diesel data…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Elements Of Electromagnetics
Mechanical Engineering
ISBN:9780190698614
Author:Sadiku, Matthew N. O.
Publisher:Oxford University Press
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:9780134319650
Author:Russell C. Hibbeler
Publisher:PEARSON
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:9781259822674
Author:Yunus A. Cengel Dr., Michael A. Boles
Publisher:McGraw-Hill Education
Control Systems Engineering
Mechanical Engineering
ISBN:9781118170519
Author:Norman S. Nise
Publisher:WILEY
Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:9781337093347
Author:Barry J. Goodno, James M. Gere
Publisher:Cengage Learning
Engineering Mechanics: Statics
Mechanical Engineering
ISBN:9781118807330
Author:James L. Meriam, L. G. Kraige, J. N. Bolton
Publisher:WILEY
Related Questions
- Could you please fix my code it’s supposed to look like the graph that’s on the picture. But the lines do not cross eachother at the beginning. Could you make the lines look like the lines on the graph? Use this code in MATLAB and fix it. % Sample data for Diesel and Petrol cars carPosition = linspace(1, 60, 50); % Assumed positions of cars % Define your seed here seed = 50; rand('seed',seed); % Set the seed for reproducibility % Assumed CO2 emissions for Diesel and Petrol 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 with a reduced degree of 2 pDiesel = polyfit(carPosition, CO2Diesel, 2); pPetrol = polyfit(carPosition, CO2Petrol, 2); % Generate points for best fit lines fitDiesel = polyval(pDiesel, carPosition); fitPetrol = polyval(pPetrol, carPosition); % Plotting the data figure; hold on; % Plot Diesel best fit line…arrow_forwardHi 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 =…arrow_forwardplease write a matlab codearrow_forward
- Motiyo Add explanationarrow_forwardMULTIPLE CHOICE -The answer is one of the options below please solve carefully and circle the correct option Please write clear .arrow_forward2. There were 42 mangoes in each crate. 12 such crates of mangoes were delivered to a factory. 4 mangoes were rotten and had to be thrown away. The remaining mangoes were packed into boxes of 10 mangoes each. Write a numerical expression in MATLAB syntax to represent this situation and then find how many boxes of mangoes were there? OFocus 4:20 AM 28°C Mostly clear 3/26/2022 LG CVENUENS THANOS BOBBLEHEAD AMANLANTE A ON CABIA ANn POCKET YOP! AVENGES KEYCHAIN INFINITY WAR Handy Fan THANOS BOBBLE HEAD IGENA ERANLIA P COs CA ANarrow_forward
- I need help with the purple line the line that you see one the graph on the picture needs to be on the graph. Use this code to add the purple line and make sure it’s crossing the orange line. Please make sure the lines are positioned the same way it is shown on the picture with the graph. Use this code on MATLAB and add the purple line. % Sample data for Diesel and Petrol cars carPosition = linspace(1, 60, 50); % Assumed positions of cars % Use the 'seed' function instead of 'rng' seed = 50; % Define your seed here rand('seed',seed); % Assumed CO2 emissions for Diesel and Petrol 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 with a reduced degree of 2 pDiesel = polyfit(carPosition, CO2Diesel, 2); pPetrol = polyfit(carPosition, CO2Petrol, 2); % Generate points for best fit lines fitDiesel = polyval(pDiesel, carPosition);…arrow_forwardHello I’m trying to make the graph that you see in the picture, I’m trying the exact copy of that graph using this code but I’m having a hard time doing that. Could you change the code so that it looks like the graph that you see on the picture using MATLAB, please send the code when you are finished. % 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; scatter(carPosition, CO2Diesel, 'o', 'MarkerEdgeColor', [1 0.5…arrow_forward3. (Make a MatLab code) You have invested money in a bank account that compounds annually. The interest rate is 6.4%. You want to know the balance of the account after 5 years. Use an initial balance of $1000.arrow_forward
- Scenario You are assigned a role as a mechanical engineer for a vehicle design manufacturing company. Your department has a software to perform numerical differentiation and integration. To be able to verify the results of using the software and validate these results, your department manager has asked you to analytically perform some tasks to validate the results generated by the software. Q: is the last two digits of your student Id number. If your number is (20110092) then Q=92. P: is the last digit of your student Id Number. If your number is (20110092) then P=2, If that digit equals zero then use P=1. Example: If your number is (20110040) then P=1. Task 1 Determine the gradient of following functions at the given points: a) x(t) = (2t7 + P t-2)² + (6vi – 5) when t = 1 5s+7 b) v(s) = when s = 3 (s²-P)2 c) i(t) = 5(1 – In(2t – 1) ) when t= 1 sec. d) V(t) =5sin(100nt + 0.2) Volts , find i(t) = 10 × x10-6 dV©) Ampere when t= 1ms. dt e) y(t) = e¬(t-n) sin(Qt + P) when t = n radian f)…arrow_forwardMatlab codingarrow_forwardUse MATLAB please make code for this.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Elements Of ElectromagneticsMechanical EngineeringISBN:9780190698614Author:Sadiku, Matthew N. O.Publisher:Oxford University PressMechanics of Materials (10th Edition)Mechanical EngineeringISBN:9780134319650Author:Russell C. HibbelerPublisher:PEARSONThermodynamics: An Engineering ApproachMechanical EngineeringISBN:9781259822674Author:Yunus A. Cengel Dr., Michael A. BolesPublisher:McGraw-Hill Education
- Control Systems EngineeringMechanical EngineeringISBN:9781118170519Author:Norman S. NisePublisher:WILEYMechanics of Materials (MindTap Course List)Mechanical EngineeringISBN:9781337093347Author:Barry J. Goodno, James M. GerePublisher:Cengage LearningEngineering Mechanics: StaticsMechanical EngineeringISBN:9781118807330Author:James L. Meriam, L. G. Kraige, J. N. BoltonPublisher:WILEY
Elements Of Electromagnetics
Mechanical Engineering
ISBN:9780190698614
Author:Sadiku, Matthew N. O.
Publisher:Oxford University Press
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:9780134319650
Author:Russell C. Hibbeler
Publisher:PEARSON
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:9781259822674
Author:Yunus A. Cengel Dr., Michael A. Boles
Publisher:McGraw-Hill Education
Control Systems Engineering
Mechanical Engineering
ISBN:9781118170519
Author:Norman S. Nise
Publisher:WILEY
Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:9781337093347
Author:Barry J. Goodno, James M. Gere
Publisher:Cengage Learning
Engineering Mechanics: Statics
Mechanical Engineering
ISBN:9781118807330
Author:James L. Meriam, L. G. Kraige, J. N. Bolton
Publisher:WILEY