@@ -242,19 +242,27 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
242
242
return only the time and output vectors.
243
243
244
244
squeeze : bool, optional
245
- If True (default), remove single-dimensional entries from the shape
246
- of the output. For single output systems, this converts the output
247
- response to a 1D array. The default value can be set using
245
+ By default, if a system is single-input, single-output (SISO) then
246
+ the output response is returned as a 1D array (indexed by time). If
247
+ squeeze=True, remove single-dimensional entries from the shape of
248
+ the output even if the system is not SISO. If squeeze=False, keep
249
+ the output as a 2D array (indexed by the output number and time)
250
+ even if the system is SISO. The default value can be set using
248
251
config.defaults['control.squeeze_time_response'].
249
252
250
253
Returns
251
254
-------
252
255
T : array
253
256
Time values of the output.
257
+
254
258
yout : array
255
- Response of the system.
259
+ Response of the system. If the system is SISO and squeeze is not
260
+ True, the array is 1D (indexed by time). If the system is not SISO or
261
+ squeeze is False, the array is 2D (indexed by the output number and
262
+ time).
263
+
256
264
xout : array
257
- Time evolution of the state vector.
265
+ Time evolution of the state vector. Not affected by squeeze.
258
266
259
267
See Also
260
268
--------
@@ -459,11 +467,9 @@ def _process_time_response(sys, tout, yout, xout, transpose=None,
459
467
yout = np .squeeze (yout )
460
468
elif squeeze is False : # squeeze no dimensions
461
469
pass
462
- # Possible code if we implement a squeeze='siso' option
463
- # elif squeeze == 'siso': # squeeze signals if SISO
464
- # yout = yout[0] if sys.issiso() else yout
470
+ elif squeeze is None : # squeeze signals if SISO
471
+ yout = yout [0 ] if sys .issiso () else yout
465
472
else :
466
- # In preparation for more complicated values for squeeze
467
473
raise ValueError ("unknown squeeze value" )
468
474
469
475
# See if we need to transpose the data back into MATLAB form
@@ -481,13 +487,17 @@ def _get_ss_simo(sys, input=None, output=None, squeeze=None):
481
487
482
488
If input is not specified, select first input and issue warning
483
489
"""
490
+ # If squeeze was not specified, figure out the default
491
+ if squeeze is None :
492
+ squeeze = config .defaults ['control.squeeze_time_response' ]
493
+
484
494
sys_ss = _convert_to_statespace (sys )
485
495
if sys_ss .issiso ():
486
496
return squeeze , sys_ss
487
- # Possible code if we implement a squeeze='siso' option
488
- # elif squeeze == ' siso':
489
- # # Don't squeeze outputs if resulting system turns out to be siso
490
- # squeeze = False
497
+ elif squeeze == None and ( input is None or output is None ):
498
+ # Don't squeeze outputs if resulting system turns out to be siso
499
+ # Note: if we expand input to allow a tuple, need to update this check
500
+ squeeze = False
491
501
492
502
warn = False
493
503
if input is None :
@@ -531,32 +541,34 @@ def step_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
531
541
many simulation steps.
532
542
533
543
X0 : array_like or float, optional
534
- Initial condition (default = 0)
535
-
536
- Numbers are converted to constant arrays with the correct shape.
544
+ Initial condition (default = 0). Numbers are converted to constant
545
+ arrays with the correct shape.
537
546
538
- input : int
547
+ input : int, optional
539
548
Index of the input that will be used in this simulation. Default = 0.
540
549
541
- output : int
550
+ output : int, optional
542
551
Index of the output that will be used in this simulation. Set to None
543
552
to not trim outputs
544
553
545
554
T_num : int, optional
546
555
Number of time steps to use in simulation if T is not provided as an
547
556
array (autocomputed if not given); ignored if sys is discrete-time.
548
557
549
- transpose : bool
558
+ transpose : bool, optional
550
559
If True, transpose all input and output arrays (for backward
551
560
compatibility with MATLAB and :func:`scipy.signal.lsim`)
552
561
553
- return_x : bool
562
+ return_x : bool, optional
554
563
If True, return the state vector (default = False).
555
564
556
565
squeeze : bool, optional
557
- If True (default), remove single-dimensional entries from the shape
558
- of the output. For single output systems, this converts the output
559
- response to a 1D array. The default value can be set using
566
+ By default, if a system is single-input, single-output (SISO) then the
567
+ output response is returned as a 1D array (indexed by time). If
568
+ squeeze=True, remove single-dimensional entries from the shape of the
569
+ output even if the system is not SISO. If squeeze=False, keep the
570
+ output as a 2D array (indexed by the output number and time) even if
571
+ the system is SISO. The default value can be set using
560
572
config.defaults['control.squeeze_time_response'].
561
573
562
574
Returns
@@ -565,10 +577,13 @@ def step_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
565
577
Time values of the output
566
578
567
579
yout : array
568
- Response of the system
580
+ Response of the system. If the system is SISO and squeeze is not
581
+ True, the array is 1D (indexed by time). If the system is not SISO or
582
+ squeeze is False, the array is 2D (indexed by the output number and
583
+ time).
569
584
570
585
xout : array, optional
571
- Individual response of each x variable (if return_x is True)
586
+ Individual response of each x variable (if return_x is True).
572
587
573
588
See Also
574
589
--------
@@ -722,19 +737,27 @@ def initial_response(sys, T=None, X0=0., input=0, output=None, T_num=None,
722
737
If True, return the state vector (default = False).
723
738
724
739
squeeze : bool, optional
725
- If True (default), remove single-dimensional entries from the shape
726
- of the output. For single output systems, this converts the output
727
- response to a 1D array. The default value can be set using
740
+ By default, if a system is single-input, single-output (SISO) then the
741
+ output response is returned as a 1D array (indexed by time). If
742
+ squeeze=True, remove single-dimensional entries from the shape of the
743
+ output even if the system is not SISO. If squeeze=False, keep the
744
+ output as a 2D array (indexed by the output number and time) even if
745
+ the system is SISO. The default value can be set using
728
746
config.defaults['control.squeeze_time_response'].
729
747
730
748
Returns
731
749
-------
732
750
T : array
733
751
Time values of the output
752
+
734
753
yout : array
735
- Response of the system
754
+ Response of the system. If the system is SISO and squeeze is not
755
+ True, the array is 1D (indexed by time). If the system is not SISO or
756
+ squeeze is False, the array is 2D (indexed by the output number and
757
+ time).
758
+
736
759
xout : array, optional
737
- Individual response of each x variable (if return_x is True)
760
+ Individual response of each x variable (if return_x is True).
738
761
739
762
See Also
740
763
--------
@@ -789,10 +812,10 @@ def impulse_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
10000
tr>789
812
790
813
Numbers are converted to constant arrays with the correct shape.
791
814
792
- input : int
815
+ input : int, optional
793
816
Index of the input that will be used in this simulation. Default = 0.
794
817
795
- output : int
818
+ output : int, optional
796
819
Index of the output that will be used in this simulation. Set to None
797
820
to not trim outputs
798
821
@@ -804,23 +827,31 @@ def impulse_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
804
827
If True, transpose all input and output arrays (for backward
805
828
compatibility with MATLAB and :func:`scipy.signal.lsim`)
806
829
807
- return_x : bool
830
+ return_x : bool, optional
808
831
If True, return the state vector (default = False).
809
832
810
833
squeeze : bool, optional
811
- If True (default), remove single-dimensional entries from the shape
812
- of the output. For single output systems, this converts the output
813
- response to a 1D array. The default value can be set using
834
+ By default, if a system is single-input, single-output (SISO) then the
835
+ output response is returned as a 1D array (indexed by time). If
836
+ squeeze=True, remove single-dimensional entries from the shape of the
837
+ output even if the system is not SISO. If squeeze=False, keep the
838
+ output as a 2D array (indexed by the output number and time) even if
839
+ the system is SISO. The default value can be set using
814
840
config.defaults['control.squeeze_time_response'].
815
841
816
842
Returns
817
843
-------
818
844
T : array
819
845
Time values of the output
846
+
820
847
yout : array
821
- Response of the system
848
+ Response of the system. If the system is SISO and squeeze is not
849
+ True, the array is 1D (indexed by time). If the system is not SISO or
850
+ squeeze is False, the array is 2D (indexed by the output number and
851
+ time).
852
+
822
853
xout : array, optional
823
- Individual response of each x variable (if return_x is True)
854
+ Individual response of each x variable (if return_x is True).
824
855
825
856
See Also
826
857
--------
0 commit comments