Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

An engineer wants to work out how much fuel a 4-cylinder internal combustion eng

ID: 3760080 • Letter: A

Question

An engineer wants to work out how much fuel a 4-cylinder internal combustion
engine uses per hour, as a function of the speed of the engine in revolutions per minute and
the dimensions of the cylinders in centimetres.
An engine cylinder of radius r can be modelled as a perfect cylinder of height, h, thus each
cylinder has a maximum volume (when the piston is at the bottom of its stroke) of
v = r^2h
The volume of fuel f (in litres) used per revolution in practice is based on the fuel-air ratio
and can be simply modelled using a constant factor, C, multiplied by the maximum cylinder
volume, v, (in litres) as follows
f = Cv
In answering this question, assume a fuel-air ratio constant of C = 0:0001.
(a) Write a MATLAB function cylinder_vol(r,h) that calculates and returns
the volume (in litres) of the engine cylinders of height h and radius r (in centimetres).
Keep in mind that 1 litre = 1000cm3.

(b) Write a MATLAB function fuel_per_rev(v) that takes the volume v of a
cylinder (in litres) and returns the fuel used for one revolution (in litres).

(c) Write a MATLAB function litres_per_hour(rpm,r,h) that takes the revolutions per minute rpm (in rpm), the height of the cylinders h (in centimetres) and the radius of the cylinders r (in centimetres) and prints the total fuel used per hour by a 4-cylinder engine (in litres) on the screen.
For example, running litres_per_hour(2000,3,10) MUST output the following format:
The fuel used at 2000 rpm is 13.5717 litres per hour.
You MUST call your cylinder_vol(r,h) and fuel_per_rev(v) functions from parts (a)
& (b).

Explanation / Answer

Write a MATLAB function cylinder_vol(r,h)

Function cylinder_vol(h,r)

function [h, r] = cylinder_vol()
h = input('Enter the height of a circle: ');
r = input('Enter the radius of a circle: ');
while(r < 0) | (h < 0)
print('Invalid input. Please try again! ');
height = input('Enter the height of a circle: ');
radius = input('Enter the radius of a circle: ');
end
h = height;
r = radius;
volOut = 3.14*(r).^2*(h);
print volOut
end

2) Write a MATLAB function fuel_per_rev(v)


   function fuel_per_rev(v)
    %This function calculates the volume of a tank shaped
    %like a rectangular cylinder with hemispheric end caps
    r=15;
    V=4/3*pi*r^3+pi*r^2*h;
    plot(h,V)
    xlabel('height in inches'), ylabel('Volume of tank')
    end

3) Write a MATLAB function litres_per_hour(rpm,r,h)

function litres_per_hour(rpm,r,h)
rpm=500; r=0.12; h=0.25;
THD=Trpm*2*pi/60;
tf=2*pi/THD;
t=linspace(0,tf,200);
TH=THD*t;
d2s=c^2-r^2*sin(TH).^2;
x=r*cos(TH)+sqrt(d2s);
xd=-r*THD*sin(TH)-(r^2*THD*sin(2*TH))./(2*sqrt(d2s));
xdd=-r*THD^2*cos(TH)-(4*r^2*THD^2*cos(2*TH).*d2s+
(r^2*sin(2*TH)*THD).^2)./(4*d2s.^(3/2));
subplot(3,1,1)
plot(t,x)
grid
xlabel('Time (s)')
ylabel('Position (m)')
subplot(3,1,2)
plot(t,xd)
grid
xlabel('Time (s)')
ylabel('Velocity (m/s)')
subplot(3,1,3)
plot(t,xdd)
grid
xlabel('Time (s)')
ylabel('Acceleration (m/s^2)')

end