Main Content

rsample

Random sampling of linear identified systems

    Description

    sysArray = rsample(sys,N) creates N random samples of the linear identified system sys. If you do not specify N, then sysArray contains ten random models.

    example

    sysArray = rsample(sys,N,stdDev) specifies the standard deviation for randomly perturbing the parameters of sys.

    example

    Examples

    collapse all

    Estimate a third-order, discrete-time, state-space model.

    load iddata2 z2;
    sys = n4sid(z2,3);

    Randomly sample the estimated model.

    N = 20;
    sys_array = rsample(sys,N);

    Analyze the uncertainty in time (step) and frequency (Bode) responses.

    figure;
    bp = bodeplot(sys_array,'g',sys,'r.');
    bp.PhaseMatchingEnabled = 'on';

    MATLAB figure

    figure;
    stepplot(sys_array,'g',sys,'r.-')

    MATLAB figure

    Estimate a third-order, discrete-time, state-space model.

    load iddata2 z2;
    sys = n4sid(z2,3);

    Randomly sample the estimated model. Specify the standard deviation level for perturbing the model parameters.

    N = 20;
    sd = 2;
    sys_array = rsample(sys,N,sd);

    Analyze the model uncertainty.

    figure;
    bode(sys_array);

    MATLAB figure

    Estimate an ARMAX model.

    load iddata1 z1
    sys = armax(z1,[2 2 2 1]);

    Randomly sample the ARMAX model. Perturb the model parameters up to 2 standard deviations.

    N = 20;
    sd = 2;
    sys_array = rsample(sys,N,sd);

    Compare the frequency response confidence region corresponding to 2 standard deviations (asymptotic estimate) with the model array response.

    bp = bodeplot(sys_array,'g',sys,'r');
    bp.PhaseMatchingEnabled = "on";
    bp.Characteristics.ConfidenceRegion.NumberOfStandardDeviations = 2;
    bp.Characteristics.ConfidenceRegion.Visible = "on";

    MATLAB figure

    Input Arguments

    collapse all

    Linear identified model, specified as one of the following model objects or an array of such objects.

    Number of sample models to generate, specified as a positive integer.

    Standard deviation for perturbing model parameters, specified as a positive scalar.

    Output Arguments

    collapse all

    Random models derived by sampling sys, returned as an array of identified models. These random models have the same structure as sys. Their parameter values are perturbed about the nominal values in a way that is consistent with the parameter covariance and based on the standard deviation stdDev.

    If sys is a single model, then sysArray is an array of length N that contains randomized samples of sys.

    If sys is an array of models, then the size of sysArray is equal to [size(sys) N]; that is, there are N randomized samples for each model in sys.

    Tips

    • For systems with large parameter uncertainties, the randomized systems in sysArray can contain unstable elements, which can make it difficult to analyze the properties of the identified system. Using analysis commands, such as step, bode, and sim, on such systems can produce unreliable results. Instead, use a dedicated Monte-Carlo analysis command, such as simsd.

    Version History

    Introduced in R2012a