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.
write a matlab script for double mass spring system with animation.
write a matlab script for double mass spring system with animation.
(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...
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
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 Write a script that simulates a card game that works as follows: A dealer...
using matlab Write a script that simulates a card game that works as follows: A dealer places 5 cards face down on the table and flips the first card. The player goes down the line, one at a time, and guesses if the next card is higher or lower than the card displayed, and then the next card is revealed. In the end, the player is awarded a point for each correct guess. In terms of coding, your script should...
Write a MATLAB script or function that returns the required initial velocity of the ping pong...
Write a MATLAB script or function that returns the required initial velocity of the ping pong ball required to launch it a specified distance. Use projectile motion equations. Keep in mind that the initial firing height will change depending on the proposed catapult design. Primary considerations in the catapult design are accuracy and repeatability as groups will be tasked with hitting the target (cup) repeatedly at distances ranging from 7 to 9 ft. (cup moved in 6 in. increments).
MATLAB Write a script which asks the user of the program to provide an initial horizontal...
MATLAB Write a script which asks the user of the program to provide an initial horizontal position, initial vertical position, initial velocity, and angle. Create a time vector spanning from zero seconds to 100 seconds incremented at 0.01 seconds. Call the function that you created in the previous problem to calculate the trajectory and velocities of the projectile. Find the maximum height of the projectile and the time at which it reaches that point. Write a neat sentence stating what...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT