Generate input signals
u = idinput(N)
u = idinput(N,type,band,levels)
[u,freqs] = idinput(N,'sine',band,levels,sinedata)
u = idinput(N) generates input signals which are typically used for identification. N determines the number of generated input data. u is returned as a matrix or column vector:
If N is a scalar, u is a column vector with this number of rows.
N = [N nu] gives an input with nu input channels each of length N.
N = [P nu M] gives a periodic input with nu channels, each of length M*P and periodic with period P.
Default is nu = 1 and M = 1.
It is recommended that you create an iddata object from u, indicating sampling time, input names, periodicity, and so on:
u = iddata(,u);
u = idinput(N,type,band,levels) specifies the type of input signal to be generated. This argument takes one of the following values:
'rgs' — Gives a random, Gaussian signal.
'rbs' — Gives a random, binary signal. This is the default.
'prbs' — Gives a pseudorandom, binary signal.
'sine' — Gives a signal that is a sum of sinusoids. The sinusoids are chosen from the frequency grid freq = 2*pi*[1:Grid_Skip:fix(P/2)]/P intersected with pi*[band(1) band(2)]. For multi-input signals, the different inputs use different frequencies from this grid. An integer number of full periods is always delivered. The selected frequencies are obtained as [u,freqs] = idinput(....), where row ku of freqs contains the frequencies of input number ku.
The frequency contents of the signal is determined by the argument band. For the choices type = 'rs', 'rbs', and 'sine', this argument is a row vector with two entries
band = [wlow, whigh]
that determine the lower and upper bound of the passband. The frequencies wlow and whigh are expressed in fractions of the Nyquist frequency. A white noise character input is thus obtained for band = [0 1], which is also the default value.
For the choice type = 'prbs',
band = [0, B]
where B is such that the signal is constant over intervals of length 1/B (the clock period). In this case the default is band = [0 1].
The argument levels defines the input level. It is a row vector
levels = [minu, maxu]
such that the signal u will always be between the values minu and maxu for the choices type = 'rbs', 'prbs', and 'sine'. For type = 'rgs', the signal level is such that minu is the mean value of the signal, minus one standard deviation, while maxu is the mean value plus one standard deviation. Gaussian white noise with zero mean and variance one is thus obtained for levels = [-1, 1], which is also the default value.
[u,freqs] = idinput(N,'sine',band,levels,sinedata) specifies sine wave as the generated signal where sinedata= [No_of_Sinusoids, No_of_Trials, Grid_Skip], meaning that No_of_Sinusoids are equally spread over the indicated band, trying No_of_Trials different, random, relative phases, until the lowest amplitude signal is found. Default value of sindedata is [10,10,1].
If more than one period is demanded (that is, M > 1), the length of the data sequence and the period of the PRBS signal are adjusted so that an integer number of maximum length PRBS periods is always obtained. If M = 1, the period of the PRBS signal is chosen to that it is longer than P = N. In the multiple-input case, the signals are maximally shifted. This means P/nu is an upper bound for the model orders that can be estimated with such a signal.
In the 'sine' case, the sinusoids are chosen from the frequency grid
freq = 2*pi*[1:Grid_Skip:fix(P/2)]/P
intersected with pi*[band(1) band(2)]. For Grid_Skip, see below. For multiple-input signals, the different inputs use different frequencies from this grid. An integer number of full periods is always delivered. The selected frequencies are obtained as the second output argument, freqs, where row ku of freqs contains the frequencies of input number ku. The resulting signal is affected by a fifth input argument, sinedata
sinedata = [No_of_Sinusoids, No_of_Trials, Grid_Skip]
meaning that No_of_Sinusoids is equally spread over the indicated band. No_of_Trials (different, random, relative phases) are tried until the lowest amplitude signal is found.
Default: sinedata = [10,10,1];
Grid_Skip can be useful for controlling odd and even frequency multiples, for example, to detect nonlinearities of various kinds.
Create an input consisting of five sinusoids spread over the whole frequency interval. Compare the spectrum of this signal with that of its square. The frequency splitting (the square having spectral support at other frequencies) reveals the nonlinearity involved:
u = idinput([100 1 20],'sine',,,[5 10 1]); u = iddata(,u,1,'per',100); u2 = u.u.^2; u2 = iddata(,u2,1,'per',100); spectrum(etfe(u),'r*',etfe(u2),'+')
Very simple algorithms are used. The frequency contents are achieved for 'rgs' by an eighth-order Butterworth, noncausal filter, using idfilt. The same filter is used for the 'rbs' case, before making the signal binary. This means that the frequency contents are not guaranteed to be precise in this case.
For the 'sine' case, the frequencies are selected to be equally spread over the chosen grid, and each sinusoid is given a random phase. A number of trials are made, and the phases that give the smallest signal amplitude are selected. The amplitude is then scaled so as to satisfy the specifications of levels.