You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Take a system where one or more input names are appearing more than once, and return a system where the columns of the ``B`` and ``D` matrices corresponding to multiple repeated inputs have been summed together. The resulting system have unique input signal names.
345
+
346
+
To avoid accidental misuse, a warning is issued if two added colums contain non-zero entries in the same row.
347
+
348
+
# Example
349
+
350
+
A system with ``B`` matrix and input names given by
351
+
```
352
+
B = [1 0 0
353
+
0 2 0
354
+
0 0 3]
355
+
356
+
u = [:u1, :u2, :u1] # Input names
357
+
```
358
+
where the input name `:u1` appears more than once, will be reduced to
359
+
```
360
+
B = [1 0
361
+
0 2
362
+
3 0]
363
+
u = [:u1, :u2]
364
+
```
365
+
"""
366
+
functionmerge_nonunique_inputs(sys)
367
+
i =0
368
+
inputnames =copy(sys.u)
369
+
while i <length(inputnames)
370
+
i +=1
371
+
inds =findall(n == inputnames[i] for n in inputnames)
372
+
length(inds) ==1&&continue
373
+
# Check that the B-matrix entries are non-overlapping
374
+
Bi = sys.B[:, inds]
375
+
Di = sys.D[:, inds]
376
+
any(>(1), sum(.!iszero.(Bi), dims=2)) &&@warn("Input names are not unique and the multiple B-matrix columns associated with the name $(u[i]) have a non-empty intersection of non-zero entries.")
377
+
any(>(1), sum(.!iszero.(Di), dims=2)) &&@warn("Input names are not unique and the multiple D-matrix columns associated with the name $(u[i]) have a non-empty intersection of non-zero entries.")
@@ -353,27 +403,7 @@ To simplify creating complicated feedback interconnections, see `connect`.
353
403
function ControlSystemsBase.feedback(s1::NamedStateSpace{T}, s2::NamedStateSpace{T};
354
404
u1=:, w1=:,z1=:,y1=:,u2=:,y2=:,w2=[],z2=[], unique =true, kwargs...) where {T <:CS.TimeEvolution}
355
405
if!unique
356
-
i =0
357
-
s1u =copy(s1.u)
358
-
while i <length(s1u)
359
-
i +=1
360
-
inds =findall(n == s1u[i] for n in s1u)
361
-
length(inds) ==1&&continue
362
-
# Check that the B-matrix entries are non-overlapping
363
-
Bi = s1.B[:, inds]
364
-
Di = s1.D[:, inds]
365
-
any(>(1), sum(.!iszero.(Bi), dims=2)) &&error("Input names are not unique and the multiple B-matrix columns associated with the name $(u[i]) have a non-empty intersection of non-zero entries.")
366
-
any(>(1), sum(.!iszero.(Di), dims=2)) &&error("Input names are not unique and the multiple D-matrix columns associated with the name $(u[i]) have a non-empty intersection of non-zero entries.")
0 commit comments