Main Content

Simulink.sdi.setComparisonColor

Set line color in comparison plot

Since R2021b

    Description

    example

    Simulink.sdi.setComparisonColor(opt,color) sets the color of the comparison plot element opt using the RGB vector specified by color.

    Examples

    collapse all

    Open the vdp model.

    mdl = "vdp";
    open_system(mdl)

    In the model, set the value of the Mu block to 1.2. Alternatively, you can use the set_param function to set the value of the block programmatically.

    set_param("vdp/Mu","gain","1.2")

    Simulate the vdp model to create a run.

    sim(mdl);

    Set the value of the Mu block to 0.5. Then, simulate the model again to create another run.

    set_param("vdp/Mu","gain","0.5")
    sim(mdl);

    Compare the two runs. For more information about how to interactively compare data, see Compare Simulation Data.

    runIDs = Simulink.sdi.getAllRunIDs;
    runID1 = runIDs(end-1);
    runID2 = runIDs(end);
    diffResult = Simulink.sdi.compareRuns(runID1,runID2);

    Set the baseline run color to purple using a 1-by-3 RGB vector.

    Simulink.sdi.setComparisonColor("baselineColor",[0.7 0.27 1])

    Use the Simulink.sdi.getComparisonColor function to get the 1-by-3 RGB vector for the line color of the comparison run.

    compColor = Simulink.sdi.getComparisonColor("compareToColor")
    compColor = 1×3
    
        0.8510    0.3255    0.0980
    
    

    Input Arguments

    collapse all

    Comparison plot element for which to set the color, specified as:

    • "baselineColor" — Baseline signal

    • "compareToColor" — Comparison signal

    • "toleranceColor" — Tolerance band

    • "differenceColor" — Difference between baseline and comparison signals

    Example: "baselineColor"

    Line color, specified as a 1-by-3 RGB vector of doubles with values between 0 and 1.

    Example: [0.7 0.27 1]

    Data Types: double

    Version History

    Introduced in R2021b