Engineering Programming (MATLAB/Python)

Scripting engineering calculations

Use this for “A loop tries beam depths from 50 mm in 10 mm steps under 10 kN·m, 50 mm wide, 150 MPa allowed. Which depth passes first?”

Table

hₚₐₛₛ
(mm)
σ
(MPa)
First pass: hₚₐₛₛ = 90 mm, where σ = 148.1 MPa is at or under 150 MPa.
This is an example. Type your own values to start a new problem.
M
Bending moment
example
b
Width
example
σallow
Allowable stress
example · MPa
h₀
Start depth
example
Δh
Depth step
example
hₘᵢₙ
Least depth
calculated
k
Steps past the start
calculated
hₚₐₛₛ
First passing depth
calculated
σ
Stress at the passing depth
calculated · MPa

Formulas

hₘᵢₙ
=
√(6
×
M
b
× σallow
)
89.44
=
√(6
×
10,000,000
50 × 150
)
k
=
⌈
hₘᵢₙ −
h₀
Δh
⌉
4
=
⌈
89.44 − 50
10
⌉
hₚₐₛₛ
=
h₀
+
k
×
Δh
90 = 50 + 4 × 10
σ
=
6
×
M
b
×
hₚₐₛₛ
2
148.1
=
6
×
10,000,000
50 ×
90
2
Formulas are worked in N·mm. The step-by-step shows the conversions.

Assumptions

•
A solid rectangle, linear elastic: σ = 6M ÷ (bh²) at the top and bottom.
•
The loop starts at h₀ and adds Δh until σ ≤ σallow, then stops.
•
Worked in N, mm and MPa: N ÷ mm² is MPa.

Step-by-step

WE KNOW
M = 10 kN·m, b = 50 mm, σallow = 150 MPa, h₀ = 50 mm, Δh = 10 mm
FIND
least depth (hₘᵢₙ), steps past the start (k), first passing depth (hₚₐₛₛ), stress at the passing depth (σ)
Step 1 · Convert to the formula’s units
The formulas don’t work directly in the units you chose, so convert first (to N·mm).
M = 10 kN·m = 10,000,000 N·mm (1 kN·m = 10⁶ N·mm)
Step 2 · Find least depth (hₘᵢₙ)
Use hₘᵢₙ = √(6 × M ÷ (b × σallow))
Set
σ
=
6
M
bh²
equal
to
σallow
and
solve
for
h:
the
least
depth
that
passes.
hₘᵢₙ
=
√(6
×
10,000,000
50 × 150
)
hₘᵢₙ
=
√(6
×
10,000,000
7,500
)
hₘᵢₙ
=
√(
60,000,000
7,500
)
hₘᵢₙ
=
√
8
,000
hₘᵢₙ = 89.44 mm
Step 3 · Find steps past the start (k)
Use k = ⌈(hₘᵢₙ − h₀) ÷ Δh⌉
Count the steps from the start to the least depth and round up: the loop stops at the first depth past hₘᵢₙ.
k
=
⌈
89.44 − 50
10
⌉
k
=
4
Step 4 · Find first passing depth (hₚₐₛₛ)
Use hₚₐₛₛ = h₀ + k × Δh
Start
at
h₀
and
take
k
steps
of
Δh:
the
depth
the
loop
stops
at.
hₚₐₛₛ = 50 + 4 × 10
hₚₐₛₛ = 50 + 40
hₚₐₛₛ = 90 mm
Step 5 · Find stress at the passing depth (σ)
Use σ = 6 × M ÷ (b × hₚₐₛₛ²)
The
loop’s
test
at
the
depth
it
stopped
at:
σ
=
Mc
I
with
c
=
h
2
and
I
=
bh³
12
.
σ
=
6
×
10,000,000
50 ×
90
2
σ
=
6
×
10,000,000
50 × 8,100
σ
=
6
×
10,000,000
405,000
σ
=
60,000,000
405,000
σ
=
148.1
MPa
Check
Put the numbers back in. Both sides should match.
89.44
=
√(6
×
10,000,000
50 × 150
)
✓
4
=
⌈
89.44 − 50
10
⌉
✓
90 = 50 + 4 × 10 ✓
148.1
=
6
×
10,000,000
50 ×
90
2
✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.

More problem types

© 2026 SME. All rights reserved.