MATLAB code The surface area S of a ring in the shape of a torus with an inner r
ID: 3573814 • Letter: M
Question
MATLAB code
The surface area S of a ring in the shape of a torus with an inner radius r and diameter d is given by: 5 = pi^2(2r + d)d. The ring is to be plated with a thin layer of coating. The weight of the coating W can be calculated approximately as W = gamma St; where gamma is the specific weight of the coating material and t is its thickness. Write an anonymous function that calculates the weight of the coating. The function should have four input arguments, r, d, t, and gamma. Use the anonymous function to calculate the weight of a gold coating (gamma = 0.696 lb/in^3) of a ring with r = 0.35 in., d = 0.12 in., and t = 0.002 in.Explanation / Answer
% weight.m file
function W = weight(r,t,d,y)
S = pi^2 * (2*r + d) * d;
W = y*S*t;
% demo.m file
r = 0.35;
d = 0.12;
t = 0.002;
y = 0.696;
W = weight(r,d,t,y);
fprintf('The weight of gold coating is %f ',W);
% sample output
% The weight of gold coating is 0.001157
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.