funtion for surface area
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
s = pi^2(2r+d)d
W=yst
r=0.35in
d=0.12in
t=0.002in
y=0.696 lb/in^3
here is what I did:
function W = Weight(r,d,t,y)
%This function calculates the weight of the coating
%on an object with surface area S of a ring in the shape of a torus
S=pi^2*(2*r+d)*d;
W=y*S*t;
end
is that correct?
2 commentaires
Walter Roberson
le 23 Nov 2011
Homework functions that are not well commented are not correct answers.
Réponses (2)
Jan
le 23 Nov 2011
Please test your function with some test data until you are sure, that it works correctly.
0 commentaires
Walter Roberson
le 23 Nov 2011
In universities around here, failure to document what all the input arguments mean, results in automatic failure for the assignment, and failure to check that all the input arguments are within range results in marks being docked for the assignment.
There is absolutely nothing in your code to indicate that I could not, for example, pass in -17 for "d".
Calculating weight based upon density times surface area is mathematically invalid. Look at the units: if you are calculating an area then the unit for that would be distance-squared (e.g., inches squared, centimeters squared), but density is in weight per distance-cubed, so you would end up with weight per distance rather than the pure weight unit that you need to get out.
You appear to be attempting to get around this by multiplying surface area by "t" distance units. What is "t"? You have not documented what it means. One would suspect that "t" might stand for "thickness". If so, then unless your thickness is "negligible" compared to your inner and outer radii, working by calculating the surface area is not a sufficiently good approximation.
When you have a thickness of a shell around the outside of an object, in order to calculate the weight of that shell, you need to calculate the volume of the shell alone. The volume of the shell alone is the difference between the volume of the original object and the volume of the object extended by the thickness of the shell. Extending an object by the thickness of a shell decreases inner radii and increases outer radii.
You need a volume formula, not a surface-area formula.
1 commentaire
Walter Roberson
le 23 Nov 2011
As you might have observed, above, if you post homework and ask "Is it correct?", the response you get back might inform you that, "No, the formula you show is the wrong one for that purpose!"
The question "Is it correct" is very different from "Would I get full marks on this assignment if I submitted this code?" Predicting how a marker will mark particular code is not often fruitful.
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!