Main Content

Create and Plot Identified Models Using Control System Toolbox Software

This example shows how to create and plot models using the System Identification Toolbox software and Control System Toolbox software. The example requires a Control System Toolbox license.

Construct a random numeric model using the Control System Toolbox software.

rng('default');
sys0 = drss(3,3,2);

rng('default') specifies the setting of the random number generator as its default setting.

sys0 is a third-order numeric state-space model with three outputs and two inputs.

Convert sys0 to an identified state-space model and set its output noise variance.

sys = idss(sys0);
sys.NoiseVariance = 0.1*eye(3);

Generate input data for simulating the output.

u = iddata([],idinput([800 2],'rbs'));

Simulate the model output with added noise.

opt = simOptions('AddNoise',true);
y = sim(sys,u,opt);

opt is an option set specifying simulation options. y is the simulated output for sys0.

Create an input-output ( iddata ) object.

data = [y u];

Estimate the state-space model from the generated data using ssest .

estimated_ss = ssest(data(1:400));

estimated_ss is an identified state-space model.

Convert the identified state-space model to a numeric transfer function.

sys_tf = tf(estimated_ss);

Plot the model output for identified state-space model.

compare(data(401:800),estimated_ss)

Figure contains 3 axes objects. Axes object 1 with ylabel y1 contains 2 objects of type line. These objects represent Validation data (y1), estimated\_ss: 79.35%. Axes object 2 with ylabel y2 contains 2 objects of type line. These objects represent Validation data (y2), estimated\_ss: 25.28%. Axes object 3 with ylabel y3 contains 2 objects of type line. These objects represent Validation data (y3), estimated\_ss: 16.25%.

Plot the response of identified model using the Linear System Analyzer.

linearSystemAnalyzer(estimated_ss);

Figure Linear System Analyzer contains 6 axes objects and other objects of type uicontrol. Axes object 1 with title From: u1, ylabel To: y1 contains an object of type line. This object represents estimated\_ss. Axes object 2 with ylabel To: y2 contains an object of type line. This object represents estimated\_ss. Axes object 3 with ylabel To: y3 contains an object of type line. This object represents estimated\_ss. Axes object 4 with title From: u2 contains an object of type line. This object represents estimated\_ss. Axes object 5 contains an object of type line. This object represents estimated\_ss. Axes object 6 contains an object of type line. This object represents estimated\_ss.

Related Topics