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):
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
write a matlab script for double mass spring system with animation.
write a matlab script for double mass spring system with animation.
Part-1. Write a matlab code to find the height of the tallest guy in a basketball...
Part-1. Write a matlab code to find the height of the tallest guy in a basketball team (including bench, i.e., 22 players). Their height is stored in array variable H. If they are more than one player representing the tallest the program should report either height as the tallest. Use an efficient algorithm. Size the array H (find the number of elements) with the function size() in the numpy module (e.g., np.size(). Algorithm should work for any number of players....
(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”.
Write as a script in the editor window of Matlab: Concession stand. Write a program, ConcessionStand.m,...
Write as a script in the editor window of Matlab: Concession stand. Write a program, ConcessionStand.m, that uses vector-matrix multiplication to tabulate and display the cost of each of the following orders. Assume that a hot dog costs $3.00, a brat costs $3.50, and a Coke costs $2.50. ----------------------------------------------------   hot dogs brats cokes order 1    2 1 3 order 2 1 0 2 order 3 2 2 2 order 4 0 5 1
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT