In: Mechanical Engineering
General Instructions Upload Matlab files for Assignment 8 to the appropriate link on Blackboard. Upload final Matlab files (YourINITIALSfilename.m), separately. Print program flowcharts, listings (a copy of the Matlab code) and requested sample runs, and submit each on the due date. Deliverables: For each program submit a flowchart, listing of the code, a sample run and the program’s Matlab (.m) file.
Problems: 1. The “filename” in YourINITIALSfilename.m for this program is “cylinder”. Create a flowchart and a corresponding Matlab program that outputs a hollow cylinder’s inner diameter, surface area and volume when a user enters cylinder height (h), outer diameter (d) and inner diameter as a percentage (p) of outer diameter. This program must prompt the user to accept any reasonable value for height, outer diameter and percentage (0-100%). In the submitted file after the listing for the final program, provide the results for one sample run of the program with h = 1 in, d = 2 in and p = 50%.
FlOWCHART:
1. Prompt user for input of required values, viz h,d & p
2. Calculate id , surface area, volume from given values
3. Print the output as calculated values.
clear;
clc
%Input
h=input('Enter the value for height of cylinder \n');
d=input('Enter the outer diameter \n');
p=input('Enter inner diameter as % of outer diameter \n');
%Caluculations
id=p*d/100;
%Surface area = outer surface + inner surface + annular area
%You can change the formula according to your requirement of
surface area
sa=2*(pi*(d^2-id^2)/4)+(pi*d*h)+(pi*id*h);
vol=(pi*(d^2-id^2)/4)*h;
%output
fprintf('Inner diameter is %0.2f \n',id);
fprintf('Surface area is %0.2f \n',sa)
fprintf('Volume is %0.2f \n',vol);