Syntax
[V,W,M]=VofRsphere([R,M])
Input Parameter
R : | | Radius [r h]; default is [r r] |
M : | | Material such as 'Fe', 'Pb', 'Si' |
Output Parameter
V : | | Volume |
W : | | Weight |
M : | | Material |
Examples
VofRsphere(5,'Pb'); % Lead sphere with 10mm diameter
Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function calculates the volume and weight of a sphere made of a specified material. It is designed to assist in creating ballast using lead or steel balls.
Input Parameters
- R: Radius of the sphere. It can be a single value or a vector [r, h]. If a single value is provided, it defaults to [r, r].
- M: Material of the sphere, specified as a string. Default is 'Fe' (iron).
Output Results
- V: Volume of the sphere in cubic millimeters.
- W: Weight of the sphere in grams.
- M: Material of the sphere.
Algorithm Steps
- Retrieve the radius
R
from the input parameters. If R
is a single value, set it to [R, R]. Assign H
as the second element of R
and R
as the first element.
- Retrieve the material
M
from the input parameters. Default is 'Fe'.
- Define a table
Tab
with materials and their densities: 'Fe' (7.8352), 'Pb' (11.3), 'Si' (2.33), 'Holz' (0.755), 'Papier' (0.755).
- If
M
is a string, find the corresponding density sw
from the table. If M
is not a string, use M
as the density.
- Calculate the volume
V
of the sphere using the formula V = 4.1888 * R * R * H
(approximating 4/3 * pi).
- Calculate the volume
Q
of a block with the same dimensions using Q = 8 * R * R * H
.
- Calculate the weight
W
of the sphere using W = V * sw / 1000
.
- If no output is requested, print the details of the sphere and block, including diameter, radius, material, volume, and weight.
Example
To calculate the volume and weight of a lead sphere with a 10mm diameter, use:
VofRsphere(5, 'Pb');
Algorithm explaination created using ChatGPT on 2025-08-19 06:46. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21