Skip to content

Commit 945d4ba

Browse files
committed
Cleanup
1 parent f771a71 commit 945d4ba

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

mwes/mwe_04.jl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ wcs.test = true
2222

2323
winch = Winch(wcs, set)
2424

25-
function finite_jacobian(f, x; ϵ=sqrt(eps(eltype(x))))
26-
n = length(x)
27-
m = length(f(x))
28-
J = zeros(m, n)
29-
for i in 1:n
30-
Δx = zeros(n)
31-
Δx[i] = ϵ
32-
J[:, i] = (f(x + Δx) - f(x - Δx)) ./ (2ϵ)
33-
end
34-
J
35-
end
36-
3725
# find equilibrium speed
3826
function find_equilibrium_speed(winch, set_speed, force, n=10000)
3927
last_v_act = 0.0
@@ -66,8 +54,8 @@ function linearize(winch, v_set, force)
6654
v_act = find_equilibrium_speed(winch, v_set, force)
6755
x0 = [v_act] # State at operating point
6856
u0 = [v_set, force] # Input at operating point
69-
A = finite_jacobian(x -> motor_dynamics(x, u0), x0)
70-
B = finite_jacobian(u -> motor_dynamics(x0, u), u0)
57+
A = finite_difference_jacobian(x -> motor_dynamics(x, u0), x0)
58+
B = finite_difference_jacobian(u -> motor_dynamics(x0, u), u0)
7159
C = [1.0]
7260
D = [0.0 0.0]
7361
siso_sys = ss(A, B[:, 1], C, D[:, 1])

0 commit comments

Comments
 (0)