Skip to content

Commit b918e7d

Browse files
DOC: Tweak the backlash_sum demo.
1 parent a9c0593 commit b918e7d

4 files changed

+10
-9
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1757,10 +1757,11 @@ array([ 0. , 0.025 , 0.25 , 0.85 , 1. , 0.9875, 0.45 , -0.75 ])
17571757

17581758
-----
17591759

1760-
Another example is in the script `backlash_sum_demo.py` in the `examples` directory.
1761-
It passes two cycles of a sine wave through a Prandtl-Ishlinskii model with three
1762-
backlash operations. The weights are `w = [0.25, 1.0, 0.5]`, the deadband values
1763-
are `[0.5, 1.0, 2.0]` and the initial values are all zero.
1760+
Another example is in the script `backlash_sum_demo.py` in the `examples`
1761+
directory. It passes two cycles of a sine wave with amplitude 2 through a
1762+
Prandtl-Ishlinskii model with three backlash operations. The weights are
1763+
`w = [0.125, 0.25, 0.25]`, the deadband values are `[0.5, 1.0, 1.5]`, and
1764+
the initial values are all zero.
17641765

17651766
![Backlash_sum plot](https://github.com/WarrenWeckesser/ufunclab/blob/main/examples/backlash_sum_demo_x_vs_t.png)
17661767

examples/backlash_sum_demo.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55

66

77
t = np.linspace(0, 4*np.pi, 1000)
8-
x = np.sin(t)
8+
x = 2*np.sin(t)
99

10-
w = np.array([0.25, 1.0, 1.25])
11-
deadband = np.array([0.5, 1.0, 2.0])
10+
w = np.array([0.125, 0.25, 0.25])
11+
deadband = np.array([0.5, 1.0, 1.5])
1212
initial = np.zeros(3)
1313

1414
y, final = backlash_sum(x, w, deadband, initial)
1515

16-
1716
plt.figure(figsize=(6, 4))
1817
plt.plot(t, x, linewidth=2, label='x(t)')
1918
plt.plot(t, y, '--', linewidth=2, label='backlash_sum(x(t))')
2019
plt.xlabel('t')
2120
plt.title('backlash_sum')
22-
plt.legend(shadow=True)
21+
plt.legend(shadow=True, loc='upper right')
22+
plt.xlim(-0.99, 14.5)
2323
plt.grid(alpha=0.6)
2424
plt.savefig('backlash_sum_demo_x_vs_t.png')
2525

examples/backlash_sum_demo_x_vs_t.png

-3.98 KB
Loading

examples/backlash_sum_demo_y_vs_x.png

664 Bytes
Loading

0 commit comments

Comments
 (0)