Question

In: Computer Science

Part A: Write a MATLAB script to find the volume of the cylinder in gallons, as...

Part A: Write a MATLAB script to find the volume of the cylinder in gallons, as well as the tank dimensions in feet. Assume that the initial measurements are 7 meters in diameter and 11 meters tall. Display your final answers to the screen using disp and a statement without a semicolon, e.g. write the following into your script disp(‘The capacity in U.S. gallons is:’), capacity, where capacity is a variable that you defined in preceding calculations.

Part B: In the same MATLAB script, perform the same calculations for a second tank that is 3 meters in diameter and 8 meters tall. This time, use fprintf to achieve the following output (no decimals for the capacity and one decimal for the dimensions): The capacity is X gallons. The tank has a diameter of X.X ft and is X.X ft tall.

Solutions

Expert Solution

clc;clear all
%%Part-A
D=input('Enter the diameter of tank in metre: '); %User enters diameter
H=input('\nEnter the height of tank in metre: '); %User enters height
V=0.25*pi*D^2*H; %Finds volume in m^3
Vgal=264*V; %Converting to gallon
Dfeet=3.281*D; %Converting m to feet for diameter
Hfeet=3.281*H; %Converting m to feet for height
X=['The capacity in US gallons is: ',num2str(Vgal)]; %For printing using disp command
disp(X)
Y=['The diameter is: ',num2str(Dfeet),' feet and height is ',num2str(Hfeet),' feet']; %Prints D and H
disp(Y)

clc;clear all
%%Part-B
format short
format compact
D=input('Enter the diameter of tank in metre: '); %User enters diameter
H=input('\nEnter the height of tank in metre: '); %User enters height
V=0.25*pi*D^2*H; %Finds volume in m^3
Vgal=264*V; %Converting to gallon
Dfeet=3.281*D; %Converting m to feet for diameter
Hfeet=3.281*H; %Converting m to feet for height
%%Using fprintf command for printing as per specified
fprintf('\nThe capicity is %d gallons. The tank has a diameter of %.1f ft and is %.1f ft tall',Vgal,Dfeet,Hfeet)

Please upvote :)


Related Solutions

To find a positive root for , write a MATLAB script file that uses Bisection method....
To find a positive root for , write a MATLAB script file that uses Bisection method. Choose any initial value that is needed. Use absolute relative approximate error to be less than 0.01. Your code should report the number of iteration and the value of x.
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program,...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program, quadroots.m, for finding the roots of the second- order polynomial ax2 + bx + c. Use the quadratic equation. The inputs are the coefficients a,b, and c and the outputs are z1 and z2. The program should produce (exactly) the following output in the Command window when run with (a, b, c) = (1, 2, −3):
write a matlab script for double mass spring system with animation.
write a matlab script for double mass spring system with animation.
find the dimensions and volume of the right circular cylinder of maximum volume inscribed in a...
find the dimensions and volume of the right circular cylinder of maximum volume inscribed in a sphere with radius 50cm
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this...
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this new matrix to a file called “Assignment3_Question5.dat”.
Use Matlab and write entier script Problem 1. Using the information above, find y(n) for all...
Use Matlab and write entier script Problem 1. Using the information above, find y(n) for all n between 1:N. y(tn)=mx(tn)+b+r(tn) y=mx+b Plot the points on a graph, without connecting them with a line.   Use a command like: plot( x, y, ‘.r’ ) Now we want to find the “best fit” solution.   As was mentioned before, this was defined in the prior exercise. (You may wish to read this to understand how the algorithm works.)   Use the MATLAB code below. You...
3. Write a Matlab script that describes the dynamics of Pressure and Flow in the systemic...
3. Write a Matlab script that describes the dynamics of Pressure and Flow in the systemic arteries and Left Ventricle. Assume that : 1) Pressure in the Left atrium (PLA) and in the Systemic Veins (Psv) remain constant. 2) A time dependent LV compliance 3) Opening/Closing of the heart valves instantaneously with the direction of flow (i.e. valves are at an open or closed states. Use parameter values from the handout.
Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three...
Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three points A, B, and C, namely (xA, yA), (xB, yB), (xC, yC), forming a triangle, storing each in a variable (for a total of 6 variables). The script should then calculate the centroid G = (xG, yG) using xG = xA+xB+xC 3 and yG = yA+yB+yC 3 , storing each in a variable. Finally, the script should print all four points. Sample output: Enter...
Using MATLAB or Octave, Write a script that prompts the user for a multiplier, storing it...
Using MATLAB or Octave, Write a script that prompts the user for a multiplier, storing it in the variable fMultiplier. The script should them prompt the user for a number, storing it in the variabl fIn. The script should then calculate the product of these two variables, saving the result to another variable fOut, and printing it. The script should then repeat the prompt for fIn, calculation, and output twice more, using the same variable fIn and fOut all three...
Using MATLAB or Octave, Write a script that prompts the user for a minimum and maximum...
Using MATLAB or Octave, Write a script that prompts the user for a minimum and maximum real number, then generates and prints a random number in the requested range. The script should then do the same for an integer range. Sample output: Enter a minimum real value: 0.5 Enter a maximum real value: 30 A random number in the range ( 0.5000, 30.0000 ) is 1.7851 Enter a minimum integer value: -10 Enter a maximum integer value: 20 A random...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT