compare

Compare the results from two jMPC simulations. This can be useful for comparing different tuning, different implementation strategies, or even different working precision.

Syntax

compare(jMPCobj,jSIMobj1,jSIMobj2)
[dy,du] = compare(jMPCobj,jSIMobj1,jSIMobj2)

Description

compare(jMPCobj,jSIMobj1,jSIMobj2) generates a plot of the results of the two simulation runs compared against each other. Both simulations must use the same jMPC object, but may contain different tuning settings, simulation settings, or modes. A sample plot is shown below.

[dy,du] = compare(jMPCobj,jSIMobj1,jSIMobj2) returns the norm of the difference between the simulation outputs (dy) and simulation inputs (du).

Example Plot

The following plot is generated by running the linear MPC example Oscillatory SISO Example in the Examples directory. Simulation 1 is run in Matlab, Simulation 2 using the jMPC MEX Engine.

%% Compare Simulation Methods
simresultML = sim(MPC1,simopts,'matlab');
simresultMX = sim(MPC1,simopts,'mex');
compare(MPC1,simresultML,simresultMX)