updateSystem(h,sys) replaces
the dynamic system used to compute a response plot with the dynamic
system model or model array sys, and updates
the plot. If the plot with handle h contains
more than one system response, this syntax replaces the first response
in the plot. updateSystem is useful, for example,
to cause a plot in a GUI to update in response to interactive input.
See Build GUI With Interactive Plot Updates.

Replace plotted step response data with data computed from a different dynamic system model.

Suppose you have a plant model and pure integrator controller that you designed for that plant. Plot the step responses of the plant and the closed-loop system.

w = 2;
zeta = 0.5;
G = tf(w^2,[1,2*zeta*w,w^2]);
C1 = pid(0,0.621);
CL1 = feedback(G*C1,1);
h = stepplot(G,CL1);

h is the plot handle that identifies the plot created by stepplot. In this figure, G is used to compute the first response, and CL1 is used to compute the second response. This ordering corresponds to the order of inputs to stepplot.

Suppose you also have a PID controller design that you want to analyze. Create a model of the closed-loop system using this alternate controller.

Update the step plot to display the second closed-loop system instead of the first. The closed-loop system is the second response in the plot, so specify the index value 2.

updateSystem(h,CL2,2);

The updateSystem command replaces the system used to compute the second response displayed in the plot. Instead of displaying response data derived from CL1, the plot now shows data derived from CL2.

Plot to update with new system data, specified as a plot handle.
Typically, you obtain the plot handle as an output argument of a response
plotting command such as stepplot or bodeplot.
For example, the command h = bodeplot(G) returns
a handle to a plot containing the Bode response of a dynamic system, G.

System from which to compute new response data for the response
plot, specified as a dynamic system model or model array.

sys must match the plotted system that
it replaces in both I/O dimensions and array dimensions. For example,
suppose h refers to a plot that displays the
step responses of a 5-element vector of 2-input, 2-output systems.
In this case, sys must also be a 5-element vector
of 2-input, 2-output systems. The number of states in the elements
of sys need not match the number of states in
the plotted systems.