Main Content

sltest.observer.setObserverModel

Link Observer Reference block to Observer model

Since R2024b

Description

sltest.observer.setObserverModel(obsref,obsmodel) links the Observer Reference block, obsref, to the Observer model, obsmodel.. Use this function to set or change the Observer model linked to the Observer Reference block. After setting the Observer model, configure its Observer Port blocks.

example

Examples

collapse all

Open the sf_car model and add an Observer Reference block. Get the created Observer model name and handle. This example requires a Stateflow® license.

import sltest.observer.*
openExample("sf_car");

mdl_handle = get_param(gcs,"Handle");
obsref1_handle = addObserverReference(mdl_handle);
obsmod1_name = gcs;
obsmod1_handle = get_param(gcs,"Handle");

Add another Observer Reference block to the sf_car model. Get the created second Observer model name and handle. Then, save and close the second and first Observer models.

obsref2_handle = addObserverReference(mdl_handle);
obsmod2_name = gcs;
obsmod2_handle = get_param(gcs,"Handle");

save_system(obsmod2_name)
close_system(obsmod2_name)
save_system(obsmod1_name)
close_system(obsmod1_name)

Reopen the second Observer model in standalone mode. Delete the second Observer Reference block from the sf_car model. Then, link the first Observer Reference block to the second Observer model.

open_system(obsmod2_name)
delete_block(obsref2_handle)
setObserverModel(obsref1,obsmod2_name);

Input Arguments

collapse all

Observer Reference block, specified as a string, character vector, or double. Use a string or character vector to specify the path of the Observer Reference block, or use a double to specify the handle of the Observer Reference block.

Observer model, specified as a string, character vector, or double. Use a string or character vector to specify the name of the Observer model or use a double to specify the handle of the Observer model.

Version History

Introduced in R2024b