Skip to content

Commit

Permalink
Merge pull request #21 from dgrunberg/issue20
Browse files Browse the repository at this point in the history
fixed shapes before Ax+Bu calc
  • Loading branch information
petercorke authored Jul 11, 2023
2 parents 5ae65fb + b6ae4d2 commit a2fe453
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bdsim/blocks/transfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,11 @@ def output(self, t, u, x):
return list(self.C @ x)

def deriv(self, t, u, x):
xd = self.A @ x + self.B @ np.array(u)
# Reshape u and x to (N,1), i.e. column vectors, so
# no problems with broadcasting between A@x and B@u
x = x.reshape(-1, 1)
u = np.array(u).reshape(-1, 1)
xd = self.A @ x + self.B @ u
return xd.flatten()


Expand Down

0 comments on commit a2fe453

Please sign in to comment.