Skip to content
Snippets Groups Projects
Commit fc6e495d authored by Adam Friedrich Schrey's avatar Adam Friedrich Schrey
Browse files

Add support for 2 dimensional arrays and fix bug

parent 8326fb1a
No related branches found
No related tags found
1 merge request!1merge develop into master
......@@ -273,6 +273,7 @@ class DTStateSpace(DTBlock):
def __init__(self,inp,out,A,B,C,D,xo,Ts):
super(DTStateSpace, self).__init__()
self.Ts = Ts
self.xo = xo
self.ninput = len(inp)
self.noutput = len(out)
self.nstate = len(A)
......@@ -291,15 +292,26 @@ class DTStateSpace(DTBlock):
self.outpos[i] = out[i]
for i in range(0,self.nstate):
self.x[i] = xo[i]
self.xo[i] = xo[i]
def updatediscrete(self):
for i in range(0,self.noutput):
self.y[i] = 0
for j in range(0,self.nstate):
if self.C.ndim == 1:
self.y[i] = self.y[i] + self.C[j]*self.x[j]
elif self.C.ndim == 2:
#prevent [ValueError: setting an array element with a sequence.] for 2 dimensional self.C:
self.y[i] = self.y[i] + self.C[i][j]*self.x[j]
else:
print("WARNING: Can not handle self.C with dimension "+str(self.C.ndim))
for j in range(0,self.ninput):
if self.C.ndim == 1:
self.y[i] = self.y[i] + self.D[j]*self.u[j]
elif self.C.ndim == 2:
#prevent [ValueError: setting an array element with a sequence.] for 2 dimensional self.C:
self.y[i] = self.y[i] + self.D[i][j]*self.u[j]
else:
print("WARNING: Can not handle self.D with dimension "+str(self.C.ndim))
xn = numpy.zeros((self.nstate))
for i in range (0,self.nstate):
for j in range (0,self.ninput):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment